外壳 32.dll 导致问题的引用



我正在使用 3.5 的 .NET Framework 在 C# 中开发一个应用程序,具有解压缩文件的功能;但是,当我运行它时,一旦它进入解压缩方法,它就会崩溃并显示 Windows"停止工作"错误。它不会读取方法中的任何行,只是在输入时崩溃。

Description:
Stopped working
Problem signature:
Problem Event Name: CLR20r3
Problem Signature 01:   test.exe
Problem Signature 02:   0.0.0.0
Problem Signature 03:   50b03509
Problem Signature 04:   Test
Problem Signature 05:   0.0.0.0
Problem Signature 06:   50b03509
Problem Signature 07:   1
Problem Signature 08:   38
Problem Signature 09:   System.IO.FileNotFoundException
OS Version: 6.1.7601.2.1.0.256.48
Locale ID:  1033

使用"停止工作菜单"中的调试功能后,出现此错误。

Could not load file or assembly 'Interop.Shell32, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

我使用此代码在 CodeDom 编译器中导入 Shell32.dll。

Params.ReferencedAssemblies.Add("Interop.Shell32.dll");

下面是在崩溃的方法中解压缩文件的代码。

Shell32.ShellClass sc = new Shell32.ShellClass();
                Shell32.Folder SrcFlder = sc.NameSpace(source);
                Shell32.Folder DestFlder = sc.NameSpace(dest);
                Shell32.FolderItems items = SrcFlder.Items();
                DestFlder.CopyHere(items, 20); 

我不确定为什么会发生这种情况。它在原始应用程序中完美运行,但是当我使用 CodeDom(不产生错误)编译它并运行它时,就会发生这种情况。我没有正确引用 COM 吗?

无法加载文件或程序集"互操作 Shell32,版本=1.0.0.0, Culture=中性,PublicKeyToken=null'或其依赖项之一。这 系统找不到指定的文件。

引用已加载到程序集中。但应用程序找不到 COM 依赖项。

您需要在主可执行文件的根目录下安装"Interop.Shell32.dll"。

为此,在Visual Studio上,单击引用时我们有一个选项,即"复制本地" - 仅将其设置为true,依赖项将在下次构建时复制到应用程序文件夹中。

然后,您可以使用生成文件夹中存在的库文件运行应用程序。

最新更新