|
Hello. Right now I admit defeat and don't know how to do this. I have a configuration file that I have to load at runtime and interpret. This works fine for all the settings in the appSettings sections but I don't know how to get the value from the system.diagnostics section.
This is an example of an config file (in "real" a lot bigger;))
<configuration>
<appSettings>
<add key="Hello" value="World" />
</appSettings>
<system.diagnostics>
<switches>
<add name="Trace" value="4" />
</switches>
</system.diagnostics>
</configuration>
To load the file I use the OpenExeConfiguration method and most of the data I can get to, but not the "Trace" value from the system.diagnostics.
<code>
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration("c:\\projext1.exe");
MessageBox.Show(config.AppSettings.Settings["Hello"].Value);
ConfigurationSection sel = config.Sections["system.diagnostics"];
</code>
Does anybody have any idea on how to get the value? A possible solution might be to load the file into XML, but I'm still hoping on using the Configuration object. Hope you can stand my bad english and thanks to enybody that have a suggestion.
Edit: formatting... 
|
|
|
|
|
Be sure that you are: using System.Diagnostics
Then, in your code, you can use the configured switch by creating a TraceSwitch with the same name as in your config file:
TraceSwitch appSwitch = new TraceSwitch("Trace", "");
The value you want to retrieve is appSwitch.Level (which in your case will be Verbose , as you have the value set to 4 in your config file.
SkyWalker
|
|
|
|
|
I would like to draw a graph of a vector of float values and was just
wondering if this is possible in C#?
Basically, just being to draw lines (by giving it co-ordinates) would suffice, however,
have the capability to draw a vector (graph plotting) would be ideal...
Any help much appreciated!
Gerry
C# Newbie
|
|
|
|
|
hi Gerry,
Vector/advanced graphics is supported in Framework 3.0. if you are working with 1.1/2 version of the framework, this should be helpful
Charting Library
regards.
|
|
|
|
|
Look up the System.Drawing namespace. In the Graphics class you will find methods for drawing any shape you like.
---
Year happy = new Year(2007);
|
|
|
|
|
Is this only in framework 3 or any of them?
Thanks alot for your help guys,
Gerry
|
|
|
|
|
System.Drawing has always been there.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I think what he is referring to is creating your own custom control that will draw the graphics how you want using the Graphics object provided in the OnPaint method of UserControls.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios[ ^]
|
|
|
|
|
Yeah absolutely right Thomas,
For example, I'd like to have something like:
<br />
double [] dblArray = new double[5];<br />
<br />
<br />
<br />
PlotArray(dblArray);<br />
<br />
Any ideas on how to start with PlotArray( ) ?
Thanks for the help guys, much appreciated!
Gerry
|
|
|
|
|
|
that link doesn't work Sir.
I'm just looking for the best way to get the job done.
sorry if i have offended you in any way.
no hard feelings...
Gerry
|
|
|
|
|
gvanto wrote: that link doesn't work Sir.
Then you need to get MSDN fixed where you live since it is an invaluable resource for windows developers.
gvanto wrote: I'm just looking for the best way to get the job done.
The best way to start is to look at the documentation for the Graphics class we are telling you about.
led mike
|
|
|
|
|
CAn u recomment me any ebook or any good book on C# graphics and image processing..... Im new to c# and need all basic knowledge about it.........
|
|
|
|
|
|
The graphics framework in C# is called GDI+, there are plenty of good books on it. As for image processing, if you search the site, I have a number of articles on images processing in C#.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi All
the problem is this that I m monitoring a microcontroller through a serial port the serial port have to monitor continuousy. Do some one have any code to monitor the serial port continuosly that when data arrives at the serial port either a character or a number of characters the serial port read it and proces it further .
SAS ![Rose | [Rose]](https://www.codeproject.com/script/Forums/Images/rose.gif)
|
|
|
|
|
Did you try looking in the C# Articles? There is one titled "Serial Communication using C# and Whidbey".
led mike
|
|
|
|
|
i viewed that but it only shows how to communicate it doesnt monitors
any one else
any one else
any one else
any one else
SAS ![Rose | [Rose]](https://www.codeproject.com/script/Forums/Images/rose.gif)
|
|
|
|
|
If I remember correctly the Comport component in the .NET framework 2.0 has an event that gets fired when new data arrives. You might want to look up the documentation on the component http://msdn2.microsoft.com/en-us/library/ed55271k.aspx[^]
Hope this helps
WM.
What about weapons of mass-construction?
"You can always try to smash it with a wrench to fix that. It might actually work" - WillemM
|
|
|
|
|
|
Also why when I moved toolStrip and menuStrip controls to toolStip Container I added lately all event handlers where removed rendering all menu and tool strip items not working, had to manually double click each item then rename old event handler methods to new created on double click to make all things work again
basically for example event that had click stopped working and new was now click_1 so I had to remove new empty click_1 and rename old click to click_1.
Why did this happen?
|
|
|
|
|
To simplify question what is right way to move toolStrip to container?
|
|
|
|
|
For example I have RichTextBox control I inherited and added IsDirty Boolean property.
Now I wonder how can I programmicly (at run time) add event on key press to set this property to true?
I know how to do it through designer.
|
|
|
|
|
TrooperIronMan wrote: Now I wonder how can I programmicly (at run time) add event on key press to set this property to true?
I know how to do it through designer.
You have to "write code". You know... use the keyboard instead of the mouse. Yeah it's old fashioned but at least they give you a "text wizard" to do it in!
led mike
|
|
|
|
|
sure why not but exactly what code should look like, that is question?
|
|
|
|