|
Ok thx for the help but the help was a bit out of my league.
I got some source code and mainpulated it a bit.
...
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Painter_MouseDown);
this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.Painter_MouseUp);
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Painter_MouseMove);
...
Point ps = new Point();
Point pe = new Point();
private void Painter_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (flag_mouseclick == 0)
{
ps.X = e.X;
ps.Y = e.Y;
flag_mouseclick = 1;
}
pe = ps;
}
private void Painter_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
Form thisform = (Form)sender;
Graphics g = thisform.CreateGraphics();
Pen p = new Pen(Color.Blue, 2);
g.DrawLine(p, ps, pe);
ps = new Point(e.X, e.Y);
g.Dispose();
}
protected void Painter_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
Form thisform = (Form)sender;
pe = new Point(e.X, e.Y);
}
the above works around where i wanted it to.
But thx for the help none the less.
-- modified at 11:53 Friday 16th February, 2007
|
|
|
|
|
Can the Microsoft chart control take row values as double? If so how?(Any code example). And i want to plot the row values against the coloumn values.(as the coloumns contain a pointer on the chart for the specified coloumn value).
|
|
|
|
|
I am trying to search for a text in a file from my desktop whose extension i gave as .surya (Purposely) and i am not getting the results while searching as expected. But suppose i want my windows desktop search to start recognising this file extension What am i supposed to do please. I would like to have the details please to surya.raghava@gmail.com.
Surya Raghava.S
|
|
|
|
|
From within a C# application, I would like to invoke the Visual Studio command-line C++ compiler (cl.exe) to compile a simple console program (e.g., helloworld.cpp). The compiler messages should be redirected or captured to a text file.
I know the environment variables have to be set (using vcvars32.bat), but I have not had any luck in hitting on the correct sequencing and parameters for System.Diagnostics.Process methods, or the Process.StartInfo property settings. I think I'm in generally the right ball park--but maybe not.
Can anyone help?
Thanks so much,
Tom
|
|
|
|
|
I tried the following and got it working without any problems (using VS2005). I also tried it in a graphical application, storing the output in a multiline-textbox instead, without any problems. Good luck!
static void Main()
{
ProcessStartInfo psi = new ProcessStartInfo("cl.exe", " -GX c:\\hello.cpp");
psi.CreateNoWindow = true;
psi.RedirectStandardError = true;
psi.RedirectStandardOutput = true;
psi.UseShellExecute = false;
Process p = new Process();
p.StartInfo = psi;
p.ErrorDataReceived += new DataReceivedEventHandler(p_ErrorDataReceived);
p.Start();
p.BeginErrorReadLine();
string sout = p.StandardOutput.ReadToEnd();
p.WaitForExit();
StringBuilder builder = new StringBuilder();
builder.AppendLine("Error:");
foreach (String s in errData)
{
builder.AppendLine(s);
}
builder.AppendLine("Output:");
builder.AppendLine(sout);
Console.WriteLine(builder.ToString());
Console.WriteLine("Press ENTER to continue");
Console.ReadKey(true);
}
private static List<string> errData = new List<string>();
static void p_ErrorDataReceived(object sender, DataReceivedEventArgs e)
{
errData.Add(e.Data);
}
Internet - the worlds biggest dictionary
|
|
|
|
|
Thanks so much for your response! Wow, I'm impressed!
Unfortunately it didn't work for me. It appears that the appropriate environment variables have to be set.
When running from within VS2005 I had to provide the whole path to cl.exe. Even then, nothing appeared after your Error: and Output: lines.
When running outside the IDE, the program complained about not being able to find mspdb80.dll.
Do you know which environmental variables should be set up [programmatically], if that is indeed the problem?
Thanks again,
Tom
|
|
|
|
|
Sorry, no. That is a question you should ask in the C++ forum instead, since it is compiling C++ you have problems with, right?
Internet - the worlds biggest dictionary
|
|
|
|
|
Well, yes and no, but certainly thanks for setting me on the right path. With some experimentation I came up with a successful C# handler (based on your code, but with necessary environment variables set--and with directories hard coded for my computer) for a "compile and run" button as follows:
////////////////////////////
protected void CompileAndRun_Click(object sender, EventArgs e)
{
// Set up environment
Environment.SetEnvironmentVariable("INCLUDE", @"C:\Program Files\Microsoft Visual Studio 8\VC\ATLMFC\INCLUDE;C:\Program Files\Microsoft Visual Studio 8\VC\INCLUDE;C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include;C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\include;");
Environment.SetEnvironmentVariable("LIB", @"C:\Program Files\Microsoft Visual Studio 8\VC\ATLMFC\LIB;C:\Program Files\Microsoft Visual Studio 8\VC\LIB;C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib;C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\lib");
Environment.SetEnvironmentVariable("LIBPATH", @"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727;C:\Program Files\Microsoft Visual Studio 8\VC\ATLMFC\LIB");
Environment.SetEnvironmentVariable("Path", @"%Path%;C:\Program Files\Microsoft Visual Studio 8\Common7\IDE;C:\Program Files\Microsoft Visual Studio 8\VC\BIN");
// Compile program
ProcessStartInfo psi = new ProcessStartInfo("cl.exe", @" -Fec:\testCompile\hello.exe -EHsc c:\testCompile\hello.cpp");
psi.CreateNoWindow = true;
psi.RedirectStandardError = true;
psi.RedirectStandardOutput = true;
psi.UseShellExecute = false;
Process p = new Process();
p.StartInfo = psi;
p.Start();
p.WaitForExit();
compilerMessages.Text = p.StandardOutput.ReadToEnd(); ;
//Execute program
ProcessStartInfo psi2 = new ProcessStartInfo(@"c:\testCompile\hello.exe");
psi2.CreateNoWindow = true;
psi2.RedirectStandardError = true;
psi2.RedirectStandardOutput = true;
psi2.UseShellExecute = false;
Process p2 = new Process();
p2.StartInfo = psi2;
p2.Start();
p2.WaitForExit();
programOutput.Text = p2.StandardOutput.ReadToEnd();
}
/////////////
Again, thanks!
Tom
|
|
|
|
|
Glad I could help!
Internet - the worlds biggest dictionary
|
|
|
|
|
Using VS2005 (not patched), writing a ASP.Net web app, using C# for the code-behind...
I have the following function:
public bool LoadFromDataSet(DataSet ds)
{
bool bSuccess = false;
if (ds != null)
{
foreach (DataTable table in ds.Tables)
{
foreach (DataRow row in table.Rows)
{
CEmployee employee = new CEmployee();
employee.LoadFromDataRow(row);
this.Add(employee);
}
}
bSuccess = true;
}
return bSuccess;
}
the intent is to read any records that might be contained within the dataset. It is assumed that if the dataset doesn't contain any records (ds.Extendedproperties.Count == 0 ), the inner-most foreach code would not be processed. What is actually happening is that it IS processing the dataset as if there were records in it. In fact, it never exits from the inner-most loop.
To coerce the function into perform as desired, I changed the function accordingly:
public bool LoadFromDataSet(DataSet ds)
{
bool bSuccess = false;
if (ds != null)
{
if (ds.ExtendedProperties.Count > 0)
{
foreach (DataTable table in ds.Tables)
{
foreach (DataRow row in table.Rows)
{
CEmployee employee = new CEmployee();
employee.LoadFromDataRow(row);
this.Add(employee);
}
}
}
bSuccess = true;
}
return bSuccess;
}
Is there some super-secret reason that this would happen?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I've used almost exactly the same code in previous projects and never had that problem, however I will look into when I get the time, if only to prove you wrong
|
|
|
|
|
Prove me wrong? I'm just describing what I'm seeing and I want to know why it's happening. I agree that it *shouldn't* be happening.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: I'm just describing what I'm seeing and I want to know why it's happening
Forgive me, I was just saying that I've used almost identical code (albeit strongly typed) and have never seen the problem you experienced.
|
|
|
|
|
I know it is kind of over-kill, but if I am not sure what the state of the dataset will be I might write some code like this: (Note I am assuming that only one table will be returned in this situation)
if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
{}
Anyway, I guess it is just another way to skin a cat.
Ben
|
|
|
|
|
I've knocked up a quick test with a dataset containing 2 table with one column: AColumn.
It doesn't appear to have the problem you observer.
Is there perhaps a recursion problem within your employee code?
Just a thought.
I also have used similar code elsewhere with no problems.
private void button1_Click(object sender, EventArgs e)
{
textBox1.Text += "1: Running with no entries\r\n";
DataSet1 ds = new DataSet1();
LoadFromDataSet(ds);
textBox1.Text += "Finished 1\r\n";
textBox1.Text += "2: Running with entries\r\n";
DataSet1.DataTable1DataTable dtbl =
new DataSet1.DataTable1DataTable();
ds.DataTable1.AddDataTable1Row("A record 1");
ds.DataTable1.AddDataTable1Row("A record 2");
LoadFromDataSet(ds);
textBox1.Text += "Finished 2\r\n";
}
public bool LoadFromDataSet(DataSet ds)
{
bool bSuccess = false;
if (ds != null)
{
foreach (DataTable table in ds.Tables)
{
foreach (DataRow row in table.Rows)
{
textBox1.Text += "In Rows: data: " +
((DataSet1.DataTable1Row)row).AColumn + "\r\n";
}
}
bSuccess = true;
}
return bSuccess;
}
The above code works fine.
Regards
ChrisB.
|
|
|
|
|
No recursion at all. It goes into that function and starts an endless loop in the innermost foreach. According to everything I know about foreach loops, it certainly shouldn't do what I'm seeing it do. If I change it to a plain for loop, it works fine.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I'm sure you've tried it already, but have you commented out the code in the innermost foreach to see if it does the same thing?
Good luck - I hate that kind of debugging!
|
|
|
|
|
John Simmons / outlaw programmer wrote: plain for loop, it works fine.
Ok, I've had a bit of a think about it.
The for loop knows in advance how many rows / tables there are, and when it hits that limit it stops.
The foreach will keep going until it gets to the end. If your code adds a row / table to the dataset, then the foreach will then check that row / table (resulting in another execution of the inner code and another row / table being added (although I know you said there was no recursion, but that seems like the most likely scenario from the data I have available).
Why not do an overloaded version of that method that accepts a datatable rather than a dataset? then you only need to loop through the datarows in that table and load an employee for each.
ChrisB.
|
|
|
|
|
What are the actual contents of what's its looping over?
Is it repeating the 0th record? Is looping over all records multiple times? Mockup a simple test case and step through it. Is there any threading involved that might be modifying the records?
Database experts, is it possible to create circular datasets?
Todd Smith
|
|
|
|
|
things that might be worth trying:
1 Check in the debugger what the value of row actually is
2 your if checks for the number of tables in the ds but actually there could be tables that contain no rows
3 make sure that LoadFromDataRow() does not change its argument.
4 let us know when you find it
_____________________________________
Action without thought is not action
Action without emotion is not life
|
|
|
|
|
WAG: Maybe you've deleted rows from the DataSet, but you haven't yet called AcceptChanges()[^].
|
|
|
|
|
Nope. The dataset is created in the calling function and it's contents are whatever is returned by a stored procedure. The stored proc posts an out parameter that indicates normal/abnormal exit, and after that out parameter is verified), the dataset is immediately passed directly to the function in question.
Nice try, though.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Hi,
I am trying to use a particular dll bought from a company that has a strong name. As a consequence had to give a strong name to all the dlls involved in the project. Among the external Dlls that I'm using are the following microsoft application block dlls:
Microsoft.Practices.EnterpriseLibrary.Caching.dll
Microsoft.Practices.EnterpriseLibrary.Common.dll
Microsoft.Practices.EnterpriseLibrary.Configuration.dll
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.dll
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.dll
Microsoft.Practices.EnterpriseLibrary.Logging.dll
so I had them strong named using mycompany.snk key as well which went successful. And once I referenced them properly in the project it compiled without any problems. So far so good.
However when I access the Cache Factory while loading the application I get the following error:
------------------------------------------------------------------------------------------------------------
An unhandled exception of type 'System.IO.FileNotFoundException' occurred in microsoft.practices.enterpriselibrary.configuration.dll
Additional information: File or assembly name Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, or one of its dependencies, was not found.
------------------------------------------------------------------------------------------------------------
Any ideas why this is happening and how may I go around it, have been stuck with this issues since ages....
Regards,
Fahd
|
|
|
|
|
Hi,
AFAIK an exe or dll can only obtain a strong name if all other dlls it needs also have
strong names; as a result you buying a strong-named dll should not force you to do
anything, it must be perfectly possible to use it in a non-strong-named environment.
The rationale is: strong naming exists to protect an app; a protected app must be
unwilling to rely on a dll that may have been tampered with, hence it requires its
referenced dlls to be strong named, but not the other way around.
Hope this helps.
Luc Pattyn
|
|
|
|
|
thanks Luc
well its being referred to in an assembly and therefore i need to strong name it as well.
any how i managed to get the issure resolved it was a bad entry in one of the config files that referred to unsigned version...
thanks though
fahd
|
|
|
|