?
Solved

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

Posted on 2010-08-18
3
Medium Priority
?
470 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 2000 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

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

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

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

752 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