Assembly.GetExecutingAssembly() 未查找正确的路径
读取嵌入的 xml 文件
我正在使用C#
var AssemblyRef = Assembly.GetExecutingAssembly();
TextReader reader = new StreamReader(AssemblyRef.GetManifestResourceStream("Text.xml"));
:它已经工作了一段时间,但开始抛出错误。我跟踪了它正在寻找的路径,它正在 bin 文件夹的根目录中查找 dll,而不是在 Debug 或release 文件夹中。
一旦发布,这很好,但对于本地开发,我无法让我的一项功能发挥作用。
我在编译时将其设置为“调试”。任何帮助都会很棒。
I'm reading an embedded xml file using
C#:
var AssemblyRef = Assembly.GetExecutingAssembly();
TextReader reader = new StreamReader(AssemblyRef.GetManifestResourceStream("Text.xml"));
It has been working for some time, but starting throwing errors. I traced the path that it is looking for and it is looking for the dll in the root of the bin folder and not in the Debug or release folder.
Once it is published this is fine, but for local development I cannot get my one feature to work.
I have it set to Debug when compiling. Any help would be great.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您已:
You have:
我把电话改成了这个,一切都很好。
通过一项声明就可以实现这一目标。我不知道为什么。
I changed the call to this and everything is fine.
Making the call one statement made it work. I'm not sure why.