1. 症狀
您的SharePoint 2010的伺服器是不是最近一直出現這個錯誤呢?
Could not load file or assembly 'Microsoft.Office.InfoPath, Version=14.0.0.0' (...)
特別是當我們部署新的InfoPath解決方案時,我們突然之間發現,無法把模板上傳到伺服器當中去了,但是我們發現在GAC中,這個Microsoft.Office.InfoPath.dll 是存在的
問題出在哪裡?
2.分析過程
在日誌中有這麼一句話:
System.IO.FileNotFoundException: Could not load file or assembly
'Microsoft.Office.InfoPath, Version=14.0.0.0, Culture=neutral,
PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The system
cannot find the file specified.
根據前文分析,檔案是一定存在的,但為什麼呢,我們繼續開啟編譯日誌檔案
報告如下:
*** Assembly Binder Log Entry (4/12/2012 @ 12:51:23) ***
The operation failed.
Bind result: hr = 0x80131040. No description available.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
Running under executable c:\windows\system32\inetsrv\w3wp.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: User = WINDEVSP2010\SPInstaller
LOG: DisplayName = Microsoft.Office.InfoPath, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c
(Fully-specified)
LOG: Appbase = file:///C:/inetpub/wwwroot/wss/VirtualDirectories/80741441fc-0d39-48f0-954e-96614c358095/
LOG: Initial PrivatePath = C:\inetpub\wwwroot\wss\VirtualDirectories\80741441fc-0d39-48f0-954e-96614c358095\bin
LOG: Dynamic Base = C:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\root\ef3f51d0
LOG: Cache Base = C:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\root\ef3f51d0
LOG: AppName = a6d35fbc
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file:
C:\inetpub\wwwroot\wss\VirtualDirectories\80741441fc-0d39-48f0-954e-96614c358095\web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v2.0.50727\Aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v2.0.50727\config\machine.config.
LOG: Publisher policy file is found at
C:\Windows\assembly\GAC_MSIL\Policy.14.0.Microsoft.Office.InfoPath\15.0.0.0__71e9bce111e9429c\Policy.14.0.Microsoft.Office.InfoPath.config.
LOG: Publisher policy file redirect is found: 14.0.0.0 redirected to 15.0.0.0.
LOG: ProcessorArchitecture is locked to MSIL.
LOG: Post-policy reference: Microsoft.Office.InfoPath, Version=15.0.0.0,
Culture=neutral, PublicKeyToken=71e9bce111e9429c,
processorArchitecture=MSIL
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL
file:///C:/Windows/Microsoft.NET/Framework64/v2.0.50727/Temporary
ASP.NET Files/root/ef3f51d0/a6d35fbc/Microsoft.Office.InfoPath.DLL.
LOG: Attempting download of new URL
file:///C:/Windows/Microsoft.NET/Framework64/v2.0.50727/Temporary
ASP.NET
Files/root/ef3f51d0/a6d35fbc/Microsoft.Office.InfoPath/Microsoft.Office.InfoPath.DLL.
LOG: Attempting download of new URL
file:///C:/inetpub/wwwroot/wss/VirtualDirectories/80741441fc-0d39-48f0-954e-96614c358095/bin/Microsoft.Office.InfoPath.DLL.
LOG: Assembly download was successful. Attempting setup of file:
C:\inetpub\wwwroot\wss\VirtualDirectories\80741441fc-0d39-48f0-954e-96614c358095\bin\Microsoft.Office.InfoPath.dll
LOG: Entering download cache setup phase.
LOG: Assembly Name is: Microsoft.Office.InfoPath, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c
WRN: Comparing the assembly name resulted in the mismatch: Major Version
ERR: The assembly reference did not match the assembly definition found.
ERR: Setup failed with hr = 0x80131040.
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
現在我們找到原因了!好像是GAC的某個設定把14.00重定向到15.000,但是這個DLL又不支援SharePoint 2010,呵呵。
我們在執行當中開啟如下的目錄:
C:\Windows\assembly\GAC_MSIL
我發現如下的資料夾:Policy.14.0.Microsoft.Office.InfoPath 有一個子資料夾 “15.0.0.0__71e9bce111e9429c”.
我繼續檢視web.config檔案中的設定,設定中有這麼一段:
<?xml version="1.0" encoding="UTF-16"?> <configuration> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity publicKeyToken="71e9bce111e9429c" name="Microsoft.Office.InfoPath" culture="neutral"></assemblyIdentity> <bindingRedirect oldVersion="14.0.0.0" newVersion="15.0.0.0"></bindingRedirect> </dependentAssembly> </assemblyBinding> </runtime> </configuration>
哈哈找到問題了!
3.解決方案
1. 開啟“開始-執行” ,輸入: C:\Windows\Assembly\GAC_MSIL
2.刪除掉如下的資料夾:
Policy.14.0.Microsoft.Office.InfoPath
Policy.14.0.Microsoft.Office.InfoPath.Client.Internal.Host
Policy.14.0.Microsoft.Office.InfoPath.FormControl
3. 執行“ IISRESET /noforce” 重啟IIS
哈哈哈,終於可以繼續我的InfoPath的部署和開發拉!