-1

我有一个 CodeDom 设置,需要引用可执行文件目录中的一些程序集。但是,似乎只在工作目录和 GAC 中搜索这些程序集,而不是可执行目录。

var compilerOptions = new CompilerOptions {
    ReferencedAssemblies = {
        "System.dll",
        "System.Core.dll",
        "Assembly0.dll",
        "Assembly1.dll"
    }
};

C# 编译器将搜索:

  1. 应用程序工作目录
  2. 广汽

无论出于何种原因,它都不会在执行目录中搜索 Assembly0.dll 或 Assembly1.dll。

4

1 回答 1

2

“执行目录”仅与您的进程相关,与 csc.exe 进程无关。只需生成程序集引用的完整路径。使用 System.Reflection.Assembly.GetEntryAssembly().Location 轻松实现

于 2010-07-19T15:29:13.397 回答