3

我正在使用 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 吗?

4

1 回答 1

0

无法加载文件或程序集“Interop.Shell32,Version=1.0.0.0,Culture=neutral,PublicKeyToken=null”或其依赖项之一。该系统找不到指定的文件。

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

您需要在主可执行文件的根目录上拥有“Interop.Shell32.dll”。

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

然后,您可以使用构建文件夹中的库文件运行您的应用程序。

于 2012-11-24T03:19:17.183 回答