1

I'm trying to load an XML file that is an embedded resource.

I'm using the code below and it's returning an error saying the URI is too long.

base.document = XElement.Load(RStudio.Properties.Resources.TemplateDOC);

Any idea what may be wrong? I'm working with .net Framework 3.5.

Any help is welcome! Thanks in advance

4

1 回答 1

4

That's trying to use TemplateDOC as the name of a file. Assuming your resource value is actually the XML itself, you want

base.document = XElement.Parse(RStudio.Properties.Resources.TemplateDOC);

I suspect that really is what you want - because if it's an embedded resource, there isn't really a filename (or URL) you could give it to load.

If it's were an embedded resource as a separate file in the assembly, then you could use Assembly.GetManifestResourceStream and then XElement.Load(Stream).

于 2013-05-03T22:10:27.063 回答