我在C#中使用.NET框架3.5开发了一个应用程序,其功能是解压缩文件;但是,当我运行它时,当它到达解压缩方法时,它就会崩溃,而导致一个.NET“停止工作”错误。它不读取方法中的任何行,只在输入它时崩溃。
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吗?
发布于 2012-11-24 03:19:17
无法加载文件或程序集“Interop.Shell32、Version=1.0.0.0、Culture=neutral、PublicKeyToken=null”或其依赖项之一。系统找不到指定的文件。
引用已加载到程序集中。但是应用程序找不到COM依赖项。
您需要将'Interop.Shell32.dll‘放在主可执行文件的根上。
为此,在Visual上,当单击引用时,我们有一个选项,即“复制本地”--仅将其设置为true,并且依赖项将复制到下一次构建中的应用程序文件夹。
然后,您可以使用构建文件夹中的库文件运行应用程序。
https://stackoverflow.com/questions/13537850
复制相似问题