項目中的security.dll與.net架構中的項目衝突
來源:互聯網
上載者:User
今天在項目中做類比發送請求,使用了HttpWebRequest 與HttpWebResponse兩個類進行發送,當使用了GetResponse()方式時,程式內部立即就報“基礎串連已經關閉: 接收時發生錯誤” 久違了的錯誤又出現了,具體的錯誤如下: Catched Exception: [System.Net.WebException]: "基礎串連已經關閉: 接收時發生錯誤。" in <System.Web.Services>
System.Net.WebException: 基礎串連已經關閉: 接收時發生錯誤。 ---> System.EntryPointNotFoundException: 無法在 DLL“security.dll”中找到名為“EnumerateSecurityPackagesW”的進入點。
在 System.Net.UnsafeNclNativeMethods.SafeNetHandles_SECURITY.EnumerateSecurityPackagesW(Int32& pkgnum, SafeFreeContextBuffer_SECURITY& handle)
在 System.Net.SafeFreeContextBuffer.EnumeratePackages(SecurDll Dll, Int32& pkgnum, SafeFreeContextBuffer& pkgArray)
在 System.Net.SSPISecureChannelType.EnumerateSecurityPackages(Int32& pkgnum, SafeFreeContextBuffer& pkgArray)
在 System.Net.SSPIWrapper.EnumerateSecurityPackages(SSPIInterface SecModule)
在 System.Net.SSPIWrapper.GetVerifyPackageInfo(SSPIInterface secModule, String packageName, Boolean throwIfMissing)
在 System.Net.Security.SecureChannel..ctor(String hostname, Boolean serverMode, SchProtocols protocolFlags, X509Certificate serverCertificate, X509CertificateCollection clientCertificates, Boolean remoteCertRequired, Boolean checkCertName, Boolean checkCertRevocationStatus, LocalCertSelectionCallback certSelectionDelegate)
在 System.Net.Security.SslState.ValidateCreateContext(Boolean isServer, String targetHost, SslProtocols enabledSslProtocols, X509Certificate serverCertificate, X509CertificateCollection clientCertificates, Boolean remoteCertRequired, Boolean checkCertRevocationStatus, Boolean checkCertName)
在 System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result)
在 System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size)
在 System.Net.PooledStream.Write(Byte[] buffer, Int32 offset, Int32 size)
在 System.Net.ConnectStream.WriteHeaders(Boolean async)
--- 內部異常堆疊追蹤的結尾 --- 解決過程: 環境:windows2003,vs2008 尋找所有項目,尋找所有產生“security.dll”的項目,將此DLL刪除(如果是項目產生,將該項目的程式集名字換一個不要叫security,免得與微軟的衝突) 本來進行了上面的操作後,按道理是能正常調用前面說的那兩個類,但是還出現相同的問題,網上查了下資料又與同事進行了討論下,發現vs在編譯或者調 試的時候會在“Temporary ASP.NET Files”檔案加入相應的dll資訊,結果就在此檔案夾中還存在“security.dll”,此地方的這個dll一定要刪,要不然是沒 有作用的,所以這個“臨時的security.dll”一定要刪除,由於用的VS2008所以完整的刪除地址為C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727 \Temporary ASP.NET Files,然後在這個檔案夾中搜尋此dll刪除,至此“基礎串連已經關閉: 接收時發生錯誤”解決