views:

113

answers:

2

My application references another a project which has an XSD file in it.

Whats the best way to get that XSD?

I did a bit of googling and found suggestions like load the assembly and get it from that, is there no easier way?

Can anyone help?

Cheers,

Andy

+1  A: 

If the XSD is an embedded resource in the assembly, then you need to get it from the assembly.

If your project references and uses the assembly, then you won't need to load it again (you don't need 2 copies in memory).

The easiest way to get to the assembly, would be from one of the types defined in it:

Type t = typeof(TypeInOtherAssembly);
Assembly assembly = t.Assembly;
assembly.GetManifestResourceStream(...);
driis
A: 

If you've added the XSD as a resource then the easiest way is to make the auto-generated Properties.Resources class publicly visible and reference the auto-generated property. You could also keep Properties.Resources internal and add an InternalsVisibleTo attribute to allow your other assembly to have access.

Other than that approach, you can use the GetManifestResourceStream on the target assembly to extract the XSD information.

Jeff Yates