Embed xsd in C# project

D

David

Hello,
I'm using an xml schema (xsd file) to validate input xml. This xsd is
used by the C# dll and must be distributed with it. The xsd isn't
modified. So I would like to embed it in the DLL so that I don't have to
worry about the path where the file is stored... How do I embed the xsd
file into my DLL? I know how to get the file back from resource using
Assembly.GetExecutingAssembly() and
assembly.GetManifestResourceStream(...) but I don't know how to create
the resource.

Thanks,
David.
 
C

Chris Hyde

David said:
Hello,
I'm using an xml schema (xsd file) to validate input xml. This xsd is
used by the C# dll and must be distributed with it. The xsd isn't
modified. So I would like to embed it in the DLL so that I don't have to
worry about the path where the file is stored... How do I embed the xsd
file into my DLL? I know how to get the file back from resource using
Assembly.GetExecutingAssembly() and
assembly.GetManifestResourceStream(...) but I don't know how to create
the resource.

IN VS, select the file to be embedded in the Project Explorer. Look now
to the Properties window, and change the "Build Action" to Embedded
Resource.

Voila!! :)

Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top