csc.exe引用外部.dll文件

Ran*_*Rag 8 c# windows csc

我正在尝试c#使用一个简单的程序Growl C# API.

我尝试用两种不同的方式编译我的程序:

1)我将.dll文件保存在与文件相同的目录中.cs.比我跑

csc /r:Growl.Connector.dll,Growl.CoreLibrary.dll /out:test.exe *.cs
Run Code Online (Sandbox Code Playgroud)

它编译得很好,也运行良好.

2)现在我在当前工作目录中创建了一个名为的目录,growl并保存了我的所有.dll引用.

现在,当我尝试使用以下命令编译它时

csc /r:"D:\Modified\Growl_NET_Connector_SDK\libraries\growl\Growl.Connector.dll","D:
\Modified\Growl_NET_Connector_SDK\libraries\growl\Growl.CoreLibrary.dll" /out:test.exe *.cs
Run Code Online (Sandbox Code Playgroud)

它编译得很好,但是当我试图运行它时,发生了下面提到的异常.

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'Growl.Connector, Version=2.0.0.0, Culture=n
eutral, PublicKeyToken=980c2339411be384' or one of its dependencies. The system cannot find the file specified.
 at GrowlNotification.Program.Main(String[] args)
Run Code Online (Sandbox Code Playgroud)

所以,我的问题是当文件在外部文件夹.dllcsc时引用文件的正确方法是什么.

这是第二种情况的目录结构.

Jon*_*eet 10

所以,我的问题是当文件在外部文件夹中时,在csc中引用.dll文件的正确方法是什么.

您已经在构建时引用它们.您只需要在执行时使它们可用,但是当您想要运行它们时,将它们复制到与可执行文件相同的目录中.

如果这些是已签名的程序集,您也可以使用全局程序集缓存进行调查,但我个人认为只需将可执行文件与其所依赖的库保持一致即可.