Solved

can I store an xsd file in an app.config file?  If so, how

Posted on 2010-08-18
3
468 Views
Last Modified: 2013-12-17
How can I store an xsd file in my app.config file (since it is xml)?  Also, how do I read it out?

Also, I am using this code to validate my xml.  How could I do that if I was using an app.config file since I will now have a file instead of a path for the "schemaFileName" argument.

                XmlSchemaSet sc = new XmlSchemaSet();
                sc.Add(targetNamespace, schemaFileName);

                XmlReaderSettings settings = new XmlReaderSettings();
                settings.Schemas = sc;
                settings.ValidationType = ValidationType.Schema;
0
Comment
Question by:jackjohnson44
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 23

Expert Comment

by:Jens Fiederer
ID: 33466783
One method would be to encode it as a string - the Uri class has encode/decode functions available you could use.....this method sacrifices readability, though, and requires the encode to be done outside of your app to get it in....
0
 
LVL 23

Expert Comment

by:Jens Fiederer
ID: 33466890
A more readable possibility would be to roll your own config section, and include the xsd or xsds as part of it...this would require you to implement a class derived from ConfigurationSection to deal with it.
0
 
LVL 3

Accepted Solution

by:
GoJoeIsBlue earned 500 total points
ID: 33467812
If you are using "Visual Studio 2008" or "Visual Studio 2010" this is pretty easy, just do this:
1) Open your XSD-file
2) Select all content and copy
3) Right-click your project-file in Visual Studio's Solution Explorer and select "Properties" (located at the bottom)
4) Click the "Settings" tab in the properties window.
5) If all you see is a link, click the link and proceed
6) You a now precented with a grid consisting of the columns: Name, Type, Scope and Value
7) In "Name" type what ever you like your application setting to be called, eg. "MyXSD"
8) In "Type" choose "string", this should be the default choice
9) In "Scope" choose "User" if you plan to change the setting programatically, otherwise choose "Application"
10) In "Value" - paste your copied XSD-content
11) Hit CTRL+S which saves the settings

The above enables you to reach your settings like this:
string xsd = Properties.Settings.Default.MyXSD;

And  if your chose "User" as scope you can also do this:
Properties.Settings.Default.MyXSD = "<xs:schema ....> ... </xs:schema>";
Properties.Settings.Default.Save();
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question