문제

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

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top