Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/271.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在另一个dll中使用dll_C#_.net_Dll_Embed - Fatal编程技术网

C# 如何在另一个dll中使用dll

C# 如何在另一个dll中使用dll,c#,.net,dll,embed,C#,.net,Dll,Embed,我正在制作一个DLL,我必须使用另一个DLL。例如,在我的DLL中,我想使用“Ionic.Zip”组件来解压文件。 你怎么能做到 我从参考资料中找到了一些使用DLL的代码,但我不知道如何在代码中使用: 这就是功能: private System.Reflection.Assembly ResolveAssemblies(object sender, System.ResolveEventArgs e) { dynamic desiredAssembly = new System.Refle

我正在制作一个DLL,我必须使用另一个DLL。例如,在我的DLL中,我想使用“Ionic.Zip”组件来解压文件。 你怎么能做到

我从参考资料中找到了一些使用DLL的代码,但我不知道如何在代码中使用: 这就是功能:

private System.Reflection.Assembly ResolveAssemblies(object sender, System.ResolveEventArgs e)
{
   dynamic desiredAssembly = new System.Reflection.AssemblyName(e.Name);

        if (desiredAssembly.Name == "Ionic_Zip") 
        {
            return System.Reflection.Assembly.Load(Properties.Resources.Ionic_Zip);
        } 
        else {return null; }

}
以及在form_负载上:

AppDomain.CurrentDomain.AssemblyResolve += ResolveAssemblies;
但是当我想用它的时候,爱奥尼亚的Zip有错误。 例如,在我的WinForm应用程序中,我有一个类似于以下的函数来解压缩使用Ionic_-Zip组件的文件:

private void UnzipUpdtFile()
{
   // extract all files in an existing zip that uses encryption
        using (var zip = Ionic.Zip.ZipFile.Read(UpdFilePCAdrss + @"\" + spl[spl.Length - 1]))
        {
            zip.Password = ZipPassword;
            zip.ExtractAll(UpdFilePCAdrss);
        }
}

如何在这个函数中使用它?

我假设这是C#。你不能简单地添加一个引用:?为什么要将它作为资源放进去?看起来毫无意义,但无论如何,您要寻找的是AppDomain.AssemblyResolve事件如果您真的需要将其保存在资源中(为什么不引用),您可以从那里提取二进制文件,将其保存到文件中,执行
Assembly.LoadFromFile
,然后使用成员的一组调用程序。但是您需要知道所有方法的名称。为什么要将一个DLL嵌入到另一个DLL中?你想解决的实际问题是什么?