|
Please take a look at this article on devhood, http://www.devhood.com/messages/message_view-2.aspx?thread_id=70534
What I want to do is essentially have a class which contains all static members of my applications settings and have it serialized out.
Something along the lines of this,
class MySettings
{
public static bool isConstant;
public static bool doReports;
}
After serialization using the XmlSerializer class, I hope to get something like this,
<?xml version="1.0"?>
<appSettings>
<add name="isConstant" value="true">
<add name="doReports" value="false">
</appSettings>
The main reason for serializing this is because the App.exe.config is read-only, so any changes to the settings don't persist. This is where the serialization comes into play. If I can get it to output into the xml file above, I'm golden.
The problem now, is getting it into the correct format. I see two problems with this.
One, the class contains all static members so when I call XmlSerializer.Serialize( <stream>, <object to serialize> ) I don't have an object to use.
Problem two, for each member variable how to output the xml <add key="isConstant" value="true" />, etc.
This is about as far as I get . . .
[XmlRoot("appSettings")]
class Settings
{
public static bool isConstant;
public static bool doReports;
}
Which as you can see, isn't far. I don't know how to have the <add> element for each member variable. It won't let me add [XmlElement("add")] before each member variable. (it complains about using the same element name) And I don't know how to get the correct attributes into the xml.
Any ideas? Or better ways of doing this?
Thanks.
|
|
|
|
|
Is there a C# equivalent of the VB.net keyword Shared ?
IE:
Public <big>Shared </big>Function DoSomething(ByVal MyValue As Integer) As String
{
'do something
}
Steve
McLenithan
Is Bert Evil? | Homer: "Hello, operator, gimme the number for 911!"
|
|
|
|
|
static
Do you not have the documentation install it is all there.
Bo Hunter
|
|
|
|
|
That's what I thought... Just wanted to be sure;) Thanks
Steve
McLenithan
Is Bert Evil? | Homer: "Hello, operator, gimme the number for 911!"
|
|
|
|
|
Hi all,
I am trying to figure out what I need to do to write an Add in for internet explorer using C#.
What interfaces do I have to implement and where is the documentation for the IE object model.
Any help will be appreciated.
Regards,
Rahul
kingtiny@cs.cmu.edu
|
|
|
|
|
I don't know anything about this topic but if you like it I know that Wrox press has about exacctly about this topic. You can check wrox.com for more information or at least get source code for somme sample.
Mazy
No sig. available now.
|
|
|
|
|
Check out this[^] article.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
|
leppie wrote:
Check out this[^] article.
That is too cool. I was interested in this a few months ago. Did not see that one sneek in, it is bookmarked now
Rocky Moore <><
|
|
|
|
|
hi guys,
I build a class using C# Library class option. How can i make this class available in a web service?
Thanks
|
|
|
|
|
The same as you you add class to other projects. Add its assemblies to your project with ADD REFRENCE.
Mazy
No sig. available now.
|
|
|
|
|
Hi guys,
I have System.Web available,
but I don't have System.Web.Services avalaible. What should I do?
Thanks
|
|
|
|
|
Right click on REFRENCE in Solution Explorer andd click add refrence. Add your namespace from the list. The same way for your other question but you have to browse your dll .
Mazy
No sig. available now.
|
|
|
|
|
Hi All,
I add a comobobox to my form and I can't use the mouse in the edit portion. I can use it to click and move the caret, but if I try to select anything it doesn't work. Anyone know what this is? I do have the style set to the one where you can edit the box (don't remember what it's called at the moment though).
- monrobot13
|
|
|
|
|
|
monrobot13 wrote:
Anyone know what this is?
Its a bug in .NET 1.0, fixed in 1.1.
James
"I despise the city and much prefer being where a traffic jam means a line-up at McDonald's"
Me when telling a friend why I wouldn't want to live with him
|
|
|
|
|
First thanks,
Second, how would I start using the .NET 1.1 controls?
Thanks!
- monrobot13
|
|
|
|
|
That is a bit harder to answer, if you are using VS.NET 2002 you are stuck with .NET 1.0 so long as you use that for building/debugging your application.
If you have VS.NET Professional or Higher (not Academic) then you should try to get the $30 upgrade to VS.NET 2003 so you can take advantage of .NET 1.1 right out of the box.
If you can't upgrade, or don't want to; you can still make use of .NET 1.1, its just a LOT harder to do.
First, I recommend getting, installing, and learning NAnt[^] for building your application. The samples and documentation are thorough enough that it'll only take an hour or two to work out what you need to do to duplicate your VS.NET build setup in NAnt.
Once you do that, you can have NAnt target .NET 1.1 for the build and your application will be use .NET 1.1 by default, only dropping to .NET 1.0 by using a config file.
Debugging is a bit harder to do. What I did was start my application, then use VS.NET's Attach to Process command to debug that process while it was running. A very large PITA but it got the job done while I waited for VS.NET 2003 to arrive.
James
"I despise the city and much prefer being where a traffic jam means a line-up at McDonald's"
Me when telling a friend why I wouldn't want to live with him
|
|
|
|
|
Thanks again for the help James.
I just have one more question. I did some reading at the NAnt site and noticed that it doesn't seem to have support for MC++ (It has a task that wraps the "cl" complier, but I don't think this works for MC++). Am I right in assuming that? If that's the case I guess I'm SOL unless I get VS.NET 2003.
Thanks again James!
- monrobot13
|
|
|
|
|
Hi everyone...
if i select a node in a treeview that displays a panel on the form, how can i dispose of that panel after another node is selected?
I don't want to have to use the
panel1.Dispose();
method whenever a different node is selected. Can someone help a gnuB figure this out?
thanks
.gonad.
|
|
|
|
|
I'm not sure if i've understood your Problem, but what about storing a reference to the active panel and call the Dispose()-Function to this, so you don't have to close all Panels.
Roland
|
|
|
|
|
Hi All,
I would like to get the position of the cursor inside a text box. And I would like to place a combo box following the cursor as the user types in the text box. Basically I am trying to bring "Intellisense features " Inside the text box. Can any one suggest me some methods to do this ?
Thanks and Regards
Balachandar Ganesan.
|
|
|
|
|
|
Hi all!
I'm working on a .NET data provider, and the DateTime Constructor is killing me. The data is coming from a byte array (which is an ODBC TimeStamp structure) and I'm tearing it apart and stuffing it into a DateTime.
In my test application, it takes me 10+ seconds to return 10,000 records from the DB. If I comment out the DateTime constructor line and just return null for the DateTime, it only takes 2 seconds to return the 10,000 records.
So far, I've tried every constructor to see if there was any different performance. The only constructor that had any difference was the DateTime(long) (ie, number of ticks since 1/1/1), but how do you calculate how many ticks a given date is?.
All of the properties are read-only, so I can't create a temp DateTime and just set my values (or can I?). I'm really kind of at a loss here...
Anyone have any ideas?
Josh
Find a penny, pick it up, and all day long you'll have a back-ache...
|
|
|
|
|
You might consider running the fetch in a thread so that the user is less affected by the delay.
α.γεεκ Fortune passes everywhere. Duke Leto Atreides
|
|
|
|