![](/img/trans.png)
[英]Webpart “Not registered as safe” after changing AssemblyVersion
[英]How can I see to it that my WebPart is found and registered as safe?
在調試WebPart以查看其控件為何不顯示的過程中,我將頁面置於瀏覽器中的編輯模式下,首先刪除了WebPart的所有多余實例,以便僅執行一次CreateChildControls()等方法。
但是,這樣做(將頁面置於“編輯”模式),我看到每個WebPart都包含以下err msg:
Web部件錯誤:無法顯示或導入此頁面上的Web部件或Web窗體控件。 找不到WebFormPDFGen.WebFormPDFGenWebPart.WebFormPDFGenWebPart,WebFormPDFGen,版本= 1.0.0.0,文化=中性,PublicKeyToken = 42314blabla類型或未將其注冊為安全類型。
什么? 找不到WebFormPDFGen.WebFormPDFGenWebPart.WebFormPDFGenWebPart嗎? 解決方案名稱為WebFormPDFGen,WebPart名為WebFormPDFGenWebPart,.cs和.webpart文件也是如此:
WebFormPDFGenWebPart.webpart確實包含對無法找到的實體(WebFormPDFGen.WebFormPDFGenGenPart.WebFormPDFGenWebPart)的引用:
<?xml version="1.0" encoding="utf-8"?>
<webParts>
<webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
<metaData>
<type name="WebFormPDFGen.WebFormPDFGenWebPart.WebFormPDFGenWebPart, $SharePoint.Project.AssemblyFullName$" />
<importErrorMessage>$Resources:core,ImportErrorMessage;</importErrorMessage>
</metaData>
<data>
<properties>
<property name="Title" type="string">WebFormPDFGenWebPart</property>
<property name="Description" type="string">My WebPart</property>
</properties>
</data>
</webPart>
</webParts>
那么...是否像err msg的第二部分提到的那樣,未將Webpart注冊為安全的? 我需要怎么做才能將其注冊為安全的?
我得到了同樣的問題,在基於演練一個很基本的WebPart運行時間在這里 :
當我將WebPart添加到測試頁面時,它呈現得很好-它具有預期的“世界,您好!” 消息基於該演練中的代碼,簡單來說就是:
[ToolboxItemAttribute(false)]
public class XMLToPDFWebPart : WebPart
{
private string customMessage = "Hello, world!";
[WebBrowsable(true),
WebDescription("Displays a custom message"),
WebDisplayName("Display Message"),
Personalizable(PersonalizationScope.User)]
public string DisplayMessage
{
get { return customMessage; }
set { customMessage = value; }
}
protected override void CreateChildControls()
{
base.CreateChildControls();
LiteralControl message = new LiteralControl();
message.Text = DisplayMessage;
Controls.Add(message);
}
...但是當我隨后在運行另一個項目/ WebPart時查看頁面時,它不僅不再歡快地鳴叫,“你好,世界!” 但是它炸毀了我下面的霧角:
Web部件錯誤:無法顯示或導入此頁面上的Web部件或Web窗體控件。 找不到類型XMLToPDF.XMLToPDFWebPart.XMLToPDFWebPart,XMLToPDF,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = 42f314BleeBlahBloo或未將其注冊為安全類型。
為什么以前顯示WebPart時現在決定WebPart丟失或不安全?
在WebPart庫中選擇並單擊2個簡單WebPart時,我得到了一個帶有相關編號的錯誤消息。 這些是日志文件中包含相關編號的行:
03/24/2015 13:33:21.37 w3wp.exe (0x1980) 0x0320 SharePoint Foundation Logging Correlation Data xmnv Medium Name=Request (GET:https://duckbilled.platypus.poisontoe:443/_layouts/WPPrevw.aspx?ID=208) 05556c29-2d56-4093-9a6a-15ed2346f3db
03/24/2015 13:33:21.39 w3wp.exe (0x1980) 0x0320 SharePoint Foundation Logging Correlation Data xmnv Medium Site=/ 05556c29-2d56-4093-9a6a-15ed2346f3db
03/24/2015 13:33:21.43 w3wp.exe (0x1980) 0x0320 Document Management Server Document Management cm6w Medium Template Discovery/InitScriptData: cannot get user profile, no UserProfileApplicationProxy exists in the current context 05556c29-2d56-4093-9a6a-15ed2346f3db
03/24/2015 13:33:21.43 w3wp.exe (0x1980) 0x0320 Document Management Server Document Management cm6w Medium Template Discovery/InitScriptData: cannot get user profile, no UserProfileApplicationProxy exists in the current context 05556c29-2d56-4093-9a6a-15ed2346f3db
03/24/2015 13:33:21.45 w3wp.exe (0x1980) 0x0320 SharePoint Foundation Monitoring b4ly High Leaving Monitored Scope (EnsureListItemsData). Execution Time=11.0956839486583 05556c29-2d56-4093-9a6a-15ed2346f3db
03/24/2015 13:33:21.46 w3wp.exe (0x1980) 0x0320 SharePoint Foundation General avro High Relying on fallback logic in VghostPageManager::getGhostDocument() for document: 'C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\Template\Features\XMLToPDF_Feature1\XMLToPDFWebPart\XMLToPDFWebPart.webpart' 05556c29-2d56-4093-9a6a-15ed2346f3db
03/24/2015 13:33:21.46 w3wp.exe (0x1980) 0x0320 SharePoint Foundation General avro High Relying on fallback logic in VghostPageManager::getGhostDocument() for document: 'C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\Template\Features\XMLToPDF_Feature1\XMLToPDFWebPart\XMLToPDFWebPart.webpart' 05556c29-2d56-4093-9a6a-15ed2346f3db
03/24/2015 13:33:21.46 w3wp.exe (0x1980) 0x0320 SharePoint Foundation General avro High Relying on fallback logic in VghostPageManager::getGhostDocument() for document: 'C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\Template\Features\XMLToPDF_Feature1\XMLToPDFWebPart\XMLToPDFWebPart.webpart' 05556c29-2d56-4093-9a6a-15ed2346f3db
03/24/2015 13:33:21.46 w3wp.exe (0x1980) 0x0320 SharePoint Foundation General avro High Relying on fallback logic in VghostPageManager::getGhostDocument() for document: 'C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\Template\Features\XMLToPDF_Feature1\XMLToPDFWebPart\XMLToPDFWebPart.webpart' 05556c29-2d56-4093-9a6a-15ed2346f3db
03/24/2015 13:33:21.46 w3wp.exe (0x1980) 0x0320 SharePoint Foundation General avro High Relying on fallback logic in VghostPageManager::getGhostDocument() for document: 'C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\Template\Features\XMLToPDF_Feature1\XMLToPDFWebPart\XMLToPDFWebPart.webpart' 05556c29-2d56-4093-9a6a-15ed2346f3db
03/24/2015 13:33:21.46 w3wp.exe (0x1980) 0x0320 SharePoint Foundation General avro High Relying on fallback logic in VghostPageManager::getGhostDocument() for document: 'C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\Template\Features\XMLToPDF_Feature1\XMLToPDFWebPart\XMLToPDFWebPart.webpart' 05556c29-2d56-4093-9a6a-15ed2346f3db
03/24/2015 13:33:21.46 w3wp.exe (0x1980) 0x0320 SharePoint Foundation General 8kh7 High Cannot complete this action. Please try again. 05556c29-2d56-4093-9a6a-15ed2346f3db
03/24/2015 13:33:21.46 w3wp.exe (0x1980) 0x0320 SharePoint Foundation General 8e2s Medium Unknown SPRequest error occurred. More information: 0x80070002 05556c29-2d56-4093-9a6a-15ed2346f3db
03/24/2015 13:33:21.47 w3wp.exe (0x1980) 0x0320 SharePoint Foundation Runtime tkau Unexpected Microsoft.SharePoint.SPException: An error occurred when previewing the Web Part. at Microsoft.SharePoint.WebPartPages.WebPartPreview.CreateChildControls() at System.Web.UI.Control.EnsureChildControls() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) 05556c29-2d56-4093-9a6a-15ed2346f3db
03/24/2015 13:33:21.57 w3wp.exe (0x1980) 0x0320 SharePoint Foundation Monitoring b4ly Medium Leaving Monitored Scope (Request (GET:https://duckbilled.platypus.poisontoe:443/_layouts/WPPrevw.aspx?ID=208)). Execution Time=208.394083605598 05556c29-2d56-4093-9a6a-15ed2346f3db
請注意,如果我現在嘗試將該WebPart添加到頁面,它會告訴我:“該操作無法完成,因為該項目已從圖庫中刪除”。
清理,重建和重新部署似乎至少可以臨時修復新的超簡單WebPart:
...但是我對它不會成為WebPart-non-grata的信心並不完全接近珠穆朗瑪峰的高度-也許是。 蒂姆。
但是,如您所見,原始WebPart仍然出現錯誤。
我建議您下載Visual Studio的加載項。 叫做CKSDev工具
這允許您執行的操作是將SharePoint解決方案打包到WSP中,然后部署該程序包,這應該注意安全控制。
這將幫助您進行調試,並且在進行SharePoint開發時通常很棒。 他們甚至為網站模板等內容添加了一些模板,可節省大量時間。
您可能必須創建一個新的SharePoint項目並遷移代碼,但是一旦CKSDev工作,您應該會很高興。
另一個選擇是找到您的Web應用程序的web.config並為您的解決方案所抱怨的程序集添加一個安全控件,但是我不會這樣做,因為在將其移至生產環境和啟動時會遇到相同的問題在處理這些文件時,很容易犯錯誤,這會使您更加痛苦。
干杯
Truez
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.