CodeDom 编译器不使用可执行目录来引用程序集
我有一个 CodeDom 设置,需要引用可执行文件目录中的一些程序集。但是,似乎只在工作目录和 GAC 中搜索这些程序集,而不是可执行目录。
var compilerOptions = new CompilerOptions {
ReferencedAssemblies = {
"System.dll",
"System.Core.dll",
"Assembly0.dll",
"Assembly1.dll"
}
};
C# 编译器将搜索:
- 应用程序工作目录
- GAC
无论出于何种原因,它都不会在执行目录中搜索 Assembly0.dll 或 Assembly1.dll。
I have a CodeDom setup that needs to reference some assemblies that are in the executable's directory. However, it appears that only the Working Directory and the GAC are searched for these assemblies, and not the executable directory.
var compilerOptions = new CompilerOptions {
ReferencedAssemblies = {
"System.dll",
"System.Core.dll",
"Assembly0.dll",
"Assembly1.dll"
}
};
The C# compiler will search:
- Application working directory
- GAC
For whatever reason it will not search for Assembly0.dll nor Assembly1.dll in the execution directory.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
“执行目录”仅与您的进程相关,与 csc.exe 进程无关。只需生成程序集引用的完整路径即可。使用 System.Reflection.Assembly.GetEntryAssembly().Location 即可轻松完成
The "execution directory" is only relevant to your process, not the csc.exe process. Just generate the full path for the assembly reference. Easy to do with System.Reflection.Assembly.GetEntryAssembly().Location