在Visual Studio 2012中使用c#,我创建了一个类库FileTube.dll,它使用了3个其他dll。我想制作一个包含这些文件的dll,因此可以通过nuget发布我的库。我尝试了3种方法都失败了:
方法1:在vistual Studio中,将“嵌入互操作程序集”设置为true,我得到此错误:
Error 2 Cannot embed interop types from assembly 'DiffieHellman.dll' because it is missing the 'GuidAttribute' attribute DiffieHellman.dll
Run Code Online (Sandbox Code Playgroud)
方法2:我使用了ILMergeGUI。它生成了用于ILMerge的代码,该代码失败并显示以下错误:对象引用未设置为对象的实例。这是命令:
"C:\Program Files (x86)\Microsoft\ILMerge\ILMerge.exe"
/ndebug
/copyattrs
/targetplatform:4.0,"C:\Windows\Microsoft.NET\Framework64\v4.0.30319"
/out:"C:\temp\z.dll"
"C:\\FileTube\TestApp\bin\Debug\FileTube.dll"
"C:\\FileTube\TestApp\bin\Debug\DiffieHellman.dll"
"C:\\FileTube\TestApp\bin\Debug\Org.Mentalis.Security.dll"
"C:\\FileTube\TestApp\bin\Debug\Tamir.SharpSSH.dll"
Run Code Online (Sandbox Code Playgroud)
方法3: 我按照本教程操作 ,使用反射来包含dll程序集。不同之处在于本教程具有一个主要的可执行文件,并且在我尝试将dll包含在我的dll中的同时,在可执行文件中包含dll。所以我将反射代码添加到主dll的类构造函数中。它可以编译,但是如果我重命名该外部dll将会失败,这意味着它没有真正加载它。
有任何想法吗?
您有几种选择:
要么
要么
AssemblyResolve处理程序,该处理程序在运行时从资源中读取并将所需的DLL返回给.NET运行时...(答案复制自:如何将多个程序集合并为一个?)
| 归档时间: |
|
| 查看次数: |
20845 次 |
| 最近记录: |