我正在C#中使用3.5的.NET Framework製作應用程序,並具有解壓縮文件的功能;然而,當我運行它時,只要它到達解壓縮方法,它就會崩潰,出現Windows「停止工作」錯誤。它不會讀取方法內的任何行,只是在輸入時崩潰。Shell32.dll參考導致問題
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嗎?
'無法加載文件或程序集 - 當您運行[ProcMon](http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx)並在發生問題時捕獲HDD活動跟蹤時,你能看到它正在尋找加載DLL的位置嗎?並與原始應用程序進行追蹤,並讓我們瞭解其差異。 –
@JeremyThompson我有ProcMan,但我似乎無法弄清楚如何捕獲硬盤活動跟蹤。如果你不介意,你能解釋一下嗎?謝謝。 – Hexo
@Hexo向下滾動頁面:http://forum.appointmentsbook.com/showthread.php?t=125 –