異常:HRESULT: 0x80070057 (E_INVALIDARG) 的處理

碰到這個異常的原因很偶然:

現象:
Solution在ReBuild過程中斷電了,來電恢復了,重析編譯整個Solution不報錯,但在瀏覽頁面時始終無法正常瀏覽,而在design的視圖中,每個aspx的首行代碼都報錯。


http://www.dezai.cn/blog/article.asp?id=355

解決過程:

搜索找到很多國內的方案,有的建議重新引用AjaxControlToolkit.dll,還有就是清除asp.net的緩存文件,但都沒有看到想要的效果,最後在一個國外MSDN的貼子(http://social.msdn.microsoft.com/Forums/en-US/csharpide/thread/352c58ec-65d8-4d77-ac7b-d2338c621ef3)中看到種種處理辦法.

相關方法可以嘗試一下,不能保證所有的方案都能達到效果,但應該也八九不離十了吧。呵呵。

方案1:清空Temporary ASP.NET Files文件夾的文件,重新編譯

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\MyWebService and recompiled and it worked fine.

這個方法是網上推薦得最多的方案,好像也可行,也不可行。裏面有些文件不能直接刪除,需要通過特殊手段進行刪除。


方案2:卸載系統上所有的Net Framework的版本,IIS,重新安裝Net Framework,IIS

這個方法好像比較麻煩,而且也不太能確定能達到解決異常的效果。就網上看到的結果而言,大多數人這樣操作並沒有解決問題。這裏要注意安裝的順序
•Uninstall .NET (Runtime and SDK)->Uninstall IIS->Install .NET (Runtime and SDK)->Install IIS


方案3:這個方法我沒看懂,就不解釋了,貌似比較複雜Background: The assembly causing me trouble was built in house and I did not have the source code.

Required: You need the Visual Studio SDK for ildasm.exe



Steps:


1.) Disassemble the .dll with the command ildasm.exe AssemblyName.dll /out:AssemblyName.il  

2.) Open the newly created AssemblyName.il with a text editor and search for "permissionset"

3.) Find and delete the following lines:


  .permissionset reqmin
             = {[mscorlib]System.Security.Permissions.PermissionSetAttribute = {property string 'Name' = string('nobody')},
                [mscorlib]System.Security.Permissions.SecurityPermissionAttribute = {property bool 'Execution' = bool(true)}}



4.) Save and rebuild the assembly with the following command: ilasm.exe AssemblyName.il /dll

5.) Throw the new dll in your bin directory or if it's strong named and needed in the GAC you can put it there.


方案4:清除 系統盤:\用戶\用戶名稱\AppData\Local\Temp\Temporary ASP.NET Files裏面的文件
C:\Users\<name>\AppData\Local\Temp\Temporary ASP.NET Files


我是用這個方案搞掂的,恰巧我的是win7的系統.不過好像這個與方案1配合使用較好.注意:Vista系統與Window7系統這個尤爲適合

來源:http://www.dezai.cn/blog/article.asp?id=355


一點心得,與大家分享。歡迎指正。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章