CSC.EXE参考外部.dll文件 [英] csc.exe reference external .dll file
问题描述
我试图让使用低吼C#API
一个简单的 C#
程序。
我试图编译我的程序有两种不同的方式:
1)我一直在我的的.dll
文件在同一目录作为我的的.cs
文件。比我跑
CSC /r:Growl.Connector.dll,Growl.CoreLibrary.dll /out:test.exe *。 CS
它编译罚款,也运行得很好。
2)现在我已经创建了一个名为咆哮
我当前的工作目录中,并保持所有的 .DLL
引用那里。
现在,当我尝试使用下面的命令
<$进行编译p $ p>
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
它编译罚款,但是当我试图运行它出现下面提到的例外
未处理的异常:System.IO。 FileNotFoundException异常:无法加载文件或程序'Growl.Connector,版本= 2.0.0.0,文化= N
eutral公钥= 980c2339411be384'或它的一个依赖。该系统找不到指定的文件。在GrowlNotification.Program.Main
(字串[] args)
所以,我的问题是什么是引用的.dll
文件中的 CSC
正确的方式,当文件在外部文件夹中。
下面是第二种情况的目录结构。
所以,我的问题是什么是引用.dll文件中CSC正确的方式,当文件在外部文件夹中。
块引用>
您已经是在的引用建立他们的时间。你只需要让他们可在执行的时间太多,但将它们复制到同一目录下的可执行文件,当你想运行它。
您也可以使用调查全局程序集缓存如果这些签名的程序集,而我个人倒只有保持与它所依赖的库可执行坚持下去。
I am trying to make a simple
c#
program usingGrowl C# API
.I tried to compile my program in two different ways:
1) I kept my
.dll
file in the same directory as my.cs
file. Than I rancsc /r:Growl.Connector.dll,Growl.CoreLibrary.dll /out:test.exe *.cs
It compiled fine and also ran fine.
2) Now I have created a directory inside my current working directory named
growl
and kept all my.dll
references there.Now when I try to compile it using the below command
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
It compiled fine but when I tried to run it the below mentioned exception occurred.
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)
So, my question is what is the correct way to reference
.dll
file incsc
when files are in an external folder.Here is the directory structure for 2nd case.
解决方案So, my question is what is the correct way to reference .dll file in csc when files are in an external folder.
You're already referencing them at build time. You just need to make them available at execution time too, but copying them into the same directory as the executable, when you want to run it.
You could also investigate using the Global Assembly Cache if these are signed assemblies, but personally I'd stick with just keeping the executable with the libraries on which it depends.
这篇关于CSC.EXE参考外部.dll文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!