473,320 Members | 1,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Create a .net 2.0 settings file problem

I am trying to create the following xml file with VS 2005:

<?xml version='1.0' encoding='utf-8'?>
<SettingsFile
xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings"
CurrentProfile="(Default)" GeneratedClassNamespace=""
GeneratedClassName="Extra">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings>
<Setting Name="Birth" Type="System.DateTime" Scope="Application">
<Value Profile="(Default)">15-09-1959</Value>
</Setting>
<Setting Name="SpecialColor" Type="System.Drawing.Color"
Scope="Application">
<Value Profile="(Default)">255; 192; 128</Value>
</Setting>
</Settings>
</SettingsFile>

I use the following code:

Dim Settings As New XmlWriterSettings

Settings.Indent = True
Settings.NewLineOnAttributes = True

Dim wr As XmlWriter = XmlWriter.Create("output.settings", Settings)

wr.WriteStartElement("SettingsFile")
' ****** This is the problem-line ******
wr.WriteAttributeString("xmlns",
"http://schemas.microsoft.com/VisualStudio/2004/01/settings")
wr.WriteAttributeString("CurrentProfile", "(Default)")
wr.WriteAttributeString("GeneratedClassNamespace", "")
wr.WriteAttributeString("GeneratedClassName", "Instellingen")

wr.WriteStartElement("Profiles")

etc. etc.

The line that starts to write the attribute xmlns is giving me problems. It
generates an exception:
The prefix '' cannot be redefined from '' to
'http://schemas.microsoft.com/VisualStudio/2004/01/settings' within the same
start element tag.

All the other lines work, but I need the xmlns attribute there.
Nov 12 '05 #1
2 4127


Danny Springer wrote:
I am trying to create the following xml file with VS 2005:

<?xml version='1.0' encoding='utf-8'?>
<SettingsFile
xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings"
CurrentProfile="(Default)" GeneratedClassNamespace=""
GeneratedClassName="Extra"> Dim wr As XmlWriter = XmlWriter.Create("output.settings", Settings)

wr.WriteStartElement("SettingsFile")
' ****** This is the problem-line ******
wr.WriteAttributeString("xmlns",
"http://schemas.microsoft.com/VisualStudio/2004/01/settings")


You need to write out the element in the proper namespace e.g.
wr.WriteStartElement("SettingsFile",
"http://schemas.microsoft.com/VisualStudio/2004/01/settings")

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Nov 12 '05 #2
Martin Honnen wrote:


Danny Springer wrote:

You need to write out the element in the proper namespace e.g.
wr.WriteStartElement("SettingsFile",
"http://schemas.microsoft.com/VisualStudio/2004/01/settings")

Ah, that's the way to do this. I'm very new in XML, now I understand.
Thank you.

Danny
Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Chad Crowder | last post by:
Getting the following error on my production server whether the file exists or not: "System.IO.IOException: Cannot create a file when that file already exists." Here's the code generating the...
3
by: VB Programmer | last post by:
I have a server that is running Windows Server 2003. My web page is trying to create a file in the C:\inetpub\wwwroot\MyWeb\Secured directory. When it tries to create/write the file it gets...
2
by: John J. Hughes II | last post by:
Ok now I guess I am supposed to save my user setting in the new setting file. Which is placed in the users application directory under the company name based on version number. I really truly...
4
by: Jamie McQuay | last post by:
Does any one know if it is possible to set the location of a settings file? I want to use separate settings files for each user and will need to change the location. Thanks, Jamie
6
by: John J. Hughes II | last post by:
I am creating a new windows service and will have a windows form for setting the runtime settings. In the past I have used the registry for this but since MS seems to think this is a bad thing I...
1
by: =?Utf-8?B?YWtpcw==?= | last post by:
Hello, I have already spent a whole day on that so some help would be greatly appreciated. I have a windows service that in the settings file (created by the designer) has a bool debug=false the...
2
by: ssg31415926 | last post by:
I've got a small web site and I've added some settings in appSettings which appear in web.config. So far, so good. I've just added a DLL to the site which was originally written to be called...
2
by: sklett | last post by:
I'm having some trouble storing a string in my settings file that contains escape characters. If I enter "This is the first line\r\nand this is the second line." When I retrieve the string from...
0
by: =?Utf-8?B?RnV0cm9uaWNzIERldmVsb3Blcg==?= | last post by:
I am trying to store a collection of custom types in a Properties.Settings file which I will be updating at run time and saving on exit of the program. I understand how to use the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.