Question

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

Était-ce utile?

La solution

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

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top