我怎样才能确定我的WebPart被发现并注册为安全?

时间:2015-03-24 15:54:07

标签: sharepoint sharepoint-2010 web-parts webpartpage

在调试我的WebPart以查看其控件未显示的原因时,我将页面置于浏览器的编辑模式中,首先删除WebPart的所有多余实例,以便我只执行CreateChildControls()等方法一次。

虽然这样做(将页面置于编辑模式),但我看到每个WebPart包含以下错误消息:

Web部件错误:无法显示或导入此页面上的Web部件或Web窗体控件。 WebFormPDFGen.WebFormPDFGenWebPart.WebFormPDFGenWebPart,WebFormPDFGen,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = 42314blabla类型无法找到或未注册为安全。

什么?找不到WebFormPDFGen.WebFormPDFGenWebPart.WebFormPDFGenWebPart?解决方案名称为WebFormPDFGen,WebPart名为WebFormPDFGenWebPart,.cs和.webpart文件也是如此:

enter image description here

WebFormPDFGenWebPart.webpart确实包含对不可创建实体的引用(WebFormPDFGen.WebFormPDFGenWebPart.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>

所以...是不是因为错误消息的第二部分提到了webpart没有注册安全?如何将其注册为安全?

更新

我在运行时使用基于演练here的非常基本的WebPart获得相同的问题:

当我将WebPart添加到我的测试页面时,它渲染得很好 - 它具有预期的&#34; Hello,world!&#34;消息基于该演练中的代码,简单地说是:

[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时查看该页面时,它不仅不再令人愉快地唧唧喳喳,而且#34;你好,世界!&#34;但它在我的脸上爆炸了下面的雾笛:

Web部件错误:无法显示或导入此页面上的Web部件或Web窗体控件。 XMLToPDF.XMLToPDFWebPart.XMLToPDFWebPart,XMLToPDF,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = 42f314BleeBlahBloo类型无法找到或未注册为安全。

为什么它现在决定WebPart丢失或不安全,何时显示它?

更新2

在选择并双击WebPart Gallery中的简单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添加到页面,它会告诉我,&#34;操作无法完成,因为该项目已从库中删除&#34;

更新3

清理,重建和[重新]部署似乎至少暂时修复了新的,超级简单的WebPart:

enter image description here

...但我对自己不会成为WebPart不受欢迎的信心并不完全接近珠穆朗玛峰的高度 - 也许是Mt.蒂姆。

但是,正如您所看到的,原始WebPart仍然会出现错误。

1 个答案:

答案 0 :(得分:1)

我建议下载Visual Studio的加载项。它被称为CKSDev工具

这使您可以将SharePoint解决方案打包到WSP中,然后部署该程序包,这应该照顾您的安全控制。

CKSDEV tools

这将有助于您进行调试,并且在SharePoint开发方面通常很棒。他们甚至为网站模板之类的东西投入了一些模板,这样可以节省大量的时间。

您可能需要创建一个新的SharePoint项目并迁移您的代码,但是一旦您的CKSDev正常工作,您应该是金色的。

另一个选择是找到您的网络应用程序的web.config,并添加一个安全控件与您的解决方案正在呻吟的程序集,但我不会这样做,因为你将它移动到同样的问题制作,当你开始玩这些文件时,很容易犯错,这会导致你更痛苦。

干杯

Truez