开发者

c# best way to grab a xsd from a referenced project

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

What开发者_StackOverflow社区s 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?


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(...);


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜