Ошибка: «Веб-часть на этой странице не может быть отображена или импортирована. Не удалось найти тип или он не зарегистрирован как безопасный»
Попытка найти сведения об этой ошибке в исходном коде, ноне совсем уверен, где именно находится проблема.
см. Эта тема для предыдущих исправлений.
Есть ли какие-нибудь указатели в хорошем месте для начала?
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
Добавлено: 26.10.2011 @ 11:36 am
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 ограничивает учетную запись пользователя на локальном компьютере (используется для запуска служб), что может привести к такому поведению?
Редактировать 03.11.2011:
Хорошо, наконецустановил "Great Practices" и он стабилен и работает.Получил исходный элемент управления, который я настраиваю для загрузки и работы как следует.
Пошел "установить" мой отредактированный элемент управления и получил это сообщение об ошибке при попытке развернуть решение:
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].