SP 2007 - Web 部件无法显示

发布于 2024-12-12 04:00:43 字数 6397 浏览 0 评论 0原文

错误:“无法显示或导入此页面上的 Web 部件。找不到该类型或未将其注册为安全类型”

尝试在源代码中查找此错误的详细信息,但不太确定确切的问题所在。

请参阅此线程了解以前执行的修复。

有没有什么好的起点可以指点一下?

DLL: TCBOE.ChartPart.dll

命名空间: TCBOE.Chartpart

FeatureReceiver.vb

Private Shared Sub AddOrRemoveChartHandlerToWebConfig(ByVal web As SPWebApplication, ByVal remove As Boolean)
    Dim asm As String = String.Format(CultureInfo.InvariantCulture, _
      "System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version={0}, Culture=neutral, PublicKeyToken={1}", _
      New Object() {"3.5.0.0", "31bf3856ad364e35"})
    Dim modif As New SPWebConfigModification("add[@path='ChartImg.axd']", _
      "configuration/system.web/httpHandlers")
    modif.Owner = "TCBOE.ChartPart"
    modif.Sequence = 0
    modif.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode

    modif.Value = String.Format(CultureInfo.InvariantCulture, _
      "<add verb=""{0}"" path=""{1}"" type=""{2}"" validate=""{3}"" />", _
      New Object() {"GET,HEAD,POST", "ChartImg.axd", asm, "false"})
    If (remove) Then
        web.WebConfigModifications.Remove(modif)
    Else
        web.WebConfigModifications.Add(modif)
    End If

End Sub
Private Shared Sub AddOrRemoveChartSettingsToWebConfig(ByVal web As SPWebApplication, ByVal remove As Boolean)
    Dim appSettings As New SPWebConfigModification("appSettings", "configuration")
    appSettings.Owner = "TCBOE.ChartPart"
    appSettings.Sequence = 0
    web.WebConfigModifications.Add(appSettings)

    Dim keyVal As String = String.Format(CultureInfo.InvariantCulture, _
     "storage={0};timeout={1};", _
     New Object() {"memory", "20"})
    Dim modif As New SPWebConfigModification("add[@key='ChartImageHandler']", "configuration/appSettings")
    modif.Owner = "TCBOE.ChartPart"
    modif.Sequence = 1
    modif.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode

    modif.Value = String.Format(CultureInfo.InvariantCulture, _
      "<add key=""{0}"" value=""{1}"" />", _
      New Object() {"ChartImageHandler", keyVal})
    If remove Then
        web.WebConfigModifications.Remove(modif)
    Else
        web.WebConfigModifications.Add(modif)
    End If
End Sub
<SharePointPermission(System.Security.Permissions.SecurityAction.Demand, ObjectModel:=True)> _
Public Overrides Sub FeatureActivated(ByVal properties As Microsoft.SharePoint.SPFeatureReceiverProperties)
    Dim site As SPSite = TryCast(properties.Feature.Parent, SPSite)
    Dim web As SPWebApplication = site.WebApplication
    AddOrRemoveChartSettingsToWebConfig(web, False)
    AddOrRemoveChartHandlerToWebConfig(web, False)
    web.Farm.Services.GetValue(Of SPWebService)().ApplyWebConfigModifications()
    web.Update()
End Sub
<SharePointPermission(System.Security.Permissions.SecurityAction.Demand, ObjectModel:=True)> _
Public Overrides Sub FeatureDeactivating(ByVal properties As Microsoft.SharePoint.SPFeatureReceiverProperties)
    Dim site As SPSite = TryCast(properties.Feature.Parent, SPSite)
    Dim web As SPWebApplication = site.WebApplication
    AddOrRemoveChartSettingsToWebConfig(web, True)
    AddOrRemoveChartHandlerToWebConfig(web, True)
    web.Farm.Services.GetValue(Of SPWebService)().ApplyWebConfigModifications()
    web.Update()
End Sub

添加:10/26/2011 @ 11:36am

Manifest.xml

(由 WSPBuilder 创建)

<?xml version="1.0"?>
<!-- Solution created by WSPBuilder. 10/26/2011 8:19:40 AM  -->
<Solution SolutionId="ee03c5c2-c9bd-4cfe-ac16-225f8e28072b" xmlns="http://schemas.microsoft.com/sharepoint/">
  <Assemblies>
    <Assembly Location="cablib.dll" DeploymentTarget="GlobalAssemblyCache" />
    <Assembly Location="TCBOE.ChartPart.dll" DeploymentTarget="GlobalAssemblyCache">
      <SafeControls>
        <SafeControl Assembly="TCBOE.ChartPart, Version=3.5.1.0, Culture=neutral, PublicKeyToken=9f4da00116c38ec5" Namespace="TCBOE.ChartPart" TypeName="*" Safe="True" />
      </SafeControls>
    </Assembly>
  </Assemblies>
  <TemplateFiles>
    <TemplateFile Location="IMAGES\ChartPartWP\oscillator_16.gif" />
    <TemplateFile Location="IMAGES\ChartPartWP\oscillator_32.gif" />
  </TemplateFiles>
  <FeatureManifests>
    <FeatureManifest Location="ChartPartWP\feature.xml" />
  </FeatureManifests>
</Solution>

是否有 CAS 策略限制本地计算机用户帐户(用于运行服务)的情况会导致这种行为?

2011 年 11 月 3 日编辑:

好的,终于得到了“伟大的实践”安装,它稳定且有效。得到了我正在定制的原始控件,以按其应有的方式加载和工作。

去“安装”我编辑的控件并在尝试部署解决方案时收到此错误响应:

Feature '47d62f5e-b0e0-4f93-bcd1-081ca794527c' could not be installed because the loading of event receiver assembly "TCBOE.ChartPart, Verstion=3.5.1.0, Culture=neutral, PublicKeyToken=9f4da00116c38ec5" failed: System.IO.FileNotFoundException: Could not load file or assembly 'TCBOE.ChartPart, Culture=neutral, PublicKeyToken=9f4da00116c38ec5' or one of its dependencies. The system cannot find the file specified. 
File name: 'TCBOE.ChartPart, Culture=neutral, PublicKeyToken=9f4da00116c38ec5' 
   at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) 
   at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) 
   at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) 
   at System.Reflection.Assembly.Load(String assemblyString) 
   at Microsoft.SharePoint.Administration.SPFeatureDefinition.get_ReceiverObject() 

WRN: Assembly binding logging is turned OFF. 
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. 
Note: There is some performance penalty associated with assembly bind failure logging. 
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

Error: "A Webpart on this Page cannot be displayed or imported. The type could not be found or it is not registered as safe"

Trying to find the details of this error in source-code but not quite sure where the exact problem is located.

refer to This Thread for previous fixes performed.

Any pointers on a good location to start?

DLL: TCBOE.ChartPart.dll

Namespace: TCBOE.Chartpart

FeatureReceiver.vb

Private Shared Sub AddOrRemoveChartHandlerToWebConfig(ByVal web As SPWebApplication, ByVal remove As Boolean)
    Dim asm As String = String.Format(CultureInfo.InvariantCulture, _
      "System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version={0}, Culture=neutral, PublicKeyToken={1}", _
      New Object() {"3.5.0.0", "31bf3856ad364e35"})
    Dim modif As New SPWebConfigModification("add[@path='ChartImg.axd']", _
      "configuration/system.web/httpHandlers")
    modif.Owner = "TCBOE.ChartPart"
    modif.Sequence = 0
    modif.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode

    modif.Value = String.Format(CultureInfo.InvariantCulture, _
      "<add verb=""{0}"" path=""{1}"" type=""{2}"" validate=""{3}"" />", _
      New Object() {"GET,HEAD,POST", "ChartImg.axd", asm, "false"})
    If (remove) Then
        web.WebConfigModifications.Remove(modif)
    Else
        web.WebConfigModifications.Add(modif)
    End If

End Sub
Private Shared Sub AddOrRemoveChartSettingsToWebConfig(ByVal web As SPWebApplication, ByVal remove As Boolean)
    Dim appSettings As New SPWebConfigModification("appSettings", "configuration")
    appSettings.Owner = "TCBOE.ChartPart"
    appSettings.Sequence = 0
    web.WebConfigModifications.Add(appSettings)

    Dim keyVal As String = String.Format(CultureInfo.InvariantCulture, _
     "storage={0};timeout={1};", _
     New Object() {"memory", "20"})
    Dim modif As New SPWebConfigModification("add[@key='ChartImageHandler']", "configuration/appSettings")
    modif.Owner = "TCBOE.ChartPart"
    modif.Sequence = 1
    modif.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode

    modif.Value = String.Format(CultureInfo.InvariantCulture, _
      "<add key=""{0}"" value=""{1}"" />", _
      New Object() {"ChartImageHandler", keyVal})
    If remove Then
        web.WebConfigModifications.Remove(modif)
    Else
        web.WebConfigModifications.Add(modif)
    End If
End Sub
<SharePointPermission(System.Security.Permissions.SecurityAction.Demand, ObjectModel:=True)> _
Public Overrides Sub FeatureActivated(ByVal properties As Microsoft.SharePoint.SPFeatureReceiverProperties)
    Dim site As SPSite = TryCast(properties.Feature.Parent, SPSite)
    Dim web As SPWebApplication = site.WebApplication
    AddOrRemoveChartSettingsToWebConfig(web, False)
    AddOrRemoveChartHandlerToWebConfig(web, False)
    web.Farm.Services.GetValue(Of SPWebService)().ApplyWebConfigModifications()
    web.Update()
End Sub
<SharePointPermission(System.Security.Permissions.SecurityAction.Demand, ObjectModel:=True)> _
Public Overrides Sub FeatureDeactivating(ByVal properties As Microsoft.SharePoint.SPFeatureReceiverProperties)
    Dim site As SPSite = TryCast(properties.Feature.Parent, SPSite)
    Dim web As SPWebApplication = site.WebApplication
    AddOrRemoveChartSettingsToWebConfig(web, True)
    AddOrRemoveChartHandlerToWebConfig(web, True)
    web.Farm.Services.GetValue(Of SPWebService)().ApplyWebConfigModifications()
    web.Update()
End Sub

Added: 10/26/2011 @ 11:36am

Manifest.xml

(As created by WSPBuilder)

<?xml version="1.0"?>
<!-- Solution created by WSPBuilder. 10/26/2011 8:19:40 AM  -->
<Solution SolutionId="ee03c5c2-c9bd-4cfe-ac16-225f8e28072b" xmlns="http://schemas.microsoft.com/sharepoint/">
  <Assemblies>
    <Assembly Location="cablib.dll" DeploymentTarget="GlobalAssemblyCache" />
    <Assembly Location="TCBOE.ChartPart.dll" DeploymentTarget="GlobalAssemblyCache">
      <SafeControls>
        <SafeControl Assembly="TCBOE.ChartPart, Version=3.5.1.0, Culture=neutral, PublicKeyToken=9f4da00116c38ec5" Namespace="TCBOE.ChartPart" TypeName="*" Safe="True" />
      </SafeControls>
    </Assembly>
  </Assemblies>
  <TemplateFiles>
    <TemplateFile Location="IMAGES\ChartPartWP\oscillator_16.gif" />
    <TemplateFile Location="IMAGES\ChartPartWP\oscillator_32.gif" />
  </TemplateFiles>
  <FeatureManifests>
    <FeatureManifest Location="ChartPartWP\feature.xml" />
  </FeatureManifests>
</Solution>

Are there any situations where a CAS policy would restrict a local-machine user account (used to run services) would cause this kind of behaviour?

Edit 11/3/2011:

Ok finally got a "Great Practices" install and it is stable and working. Got the original control i am customizing to load and working as it should.

Went to go "install" my edited control and received this error response when trying to deploy the solution:

Feature '47d62f5e-b0e0-4f93-bcd1-081ca794527c' could not be installed because the loading of event receiver assembly "TCBOE.ChartPart, Verstion=3.5.1.0, Culture=neutral, PublicKeyToken=9f4da00116c38ec5" failed: System.IO.FileNotFoundException: Could not load file or assembly 'TCBOE.ChartPart, Culture=neutral, PublicKeyToken=9f4da00116c38ec5' or one of its dependencies. The system cannot find the file specified. 
File name: 'TCBOE.ChartPart, Culture=neutral, PublicKeyToken=9f4da00116c38ec5' 
   at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) 
   at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) 
   at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) 
   at System.Reflection.Assembly.Load(String assemblyString) 
   at Microsoft.SharePoint.Administration.SPFeatureDefinition.get_ReceiverObject() 

WRN: Assembly binding logging is turned OFF. 
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. 
Note: There is some performance penalty associated with assembly bind failure logging. 
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不乱于心 2024-12-19 04:00:44

您是否使用用户控件来呈现 Web 部件?如果是这样,请将其放在 UserControl 的顶部:

<%@ Assembly Name="System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>

如果您没有使用 UserControl,只需修改代码以将该行添加到标记内的 web.config 中:

<add assembly="System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

我在另一个线程中告诉过您,您正在做尝试手动摆弄这些东西的超困难模式方式。如果您使用的是 SmartPart 或 VSeWSS 1.3,您将不会经历这一切。

Are you using an usercontrol to render the webpart? If so, put this on the top of your UserControl:

<%@ Assembly Name="System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>

If you are not using an UserControl, just modify your code to add that line to your web.config inside the tag:

<add assembly="System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

I told you this back in the other thread, you are doing the ultra-hard mode way trying to fiddle with this stuff by hand. If you were using SmartPart or VSeWSS 1.3 you would not go through all this.

喜爱纠缠 2024-12-19 04:00:43

Web 部件应在 web.config 的 SafeControls 中注册。做起来非常简单。尝试以下链接:

http://msdn.microsoft .com/en-us/library/ms581321(v=office.12).aspx

The web part should be registered in web.config's SafeControls. It's very simple to do. Try the following link:

http://msdn.microsoft.com/en-us/library/ms581321(v=office.12).aspx

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文