【问题标题】:Shell32.dll Reference Causing ProblemsShell32.dll 参考导致问题
【发布时间】:2012-11-12 08:04:03
【问题描述】:

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

【问题讨论】:

  • Could not load file or assembly - 当您运行ProcMon 并在问题发生时捕获 HDD 活动跟踪时,您能看到它正在寻找加载 DLL 的位置吗?并使用原始应用程序运行跟踪,让我们知道差异。
  • @JeremyThompson 我有 ProcMan,但我似乎无法弄清楚如何捕获 HDD 活动跟踪。如果你不介意,你能解释一下吗?谢谢。
  • 没关系,但编译后的看起来是“C:\Windows\System32\shell32.dll”,而实际看起来是“C:\Windows\SysWOW64\shell32.dll”。
  • 那么当您以 x86 为目标并进行编译时,是否会将 Shell32 引用设置为 32 位系统文件路径?

标签: c# unzip windows-shell codedom


【解决方案1】:

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

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

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

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

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

【讨论】:

  • 我已经完成了这项工作,并将编译后的文件放入包含“Interop.Shell32.dll”文件的调试文件夹中。但是它仍然给出同样的错误。
猜你喜欢
  • 1970-01-01
  • 2010-12-15
  • 1970-01-01
  • 1970-01-01
  • 2016-12-30
  • 2010-10-30
  • 2018-05-13
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多