SerializationException - Impossibile trovare di costruzione per un oggetto (grafico personalizzato Web Part)
-
16-10-2019 - |
Domanda
Per un progetto, ho creato un web-parte che deriva dalla classe ChartWebPart (al fine di impostare i dati source relativamente).
SP:
SharePoint Server 2010 (Enterprise)
cs-file:
using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.DataVisualization.Charting;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.Office.Server.WebControls;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
namespace Cbs.PP.ProjectCosts.WebParts.ProjectExpensesChartWebPart
{
[Serializable()]
[ToolboxItemAttribute(false)]
public class ProjectExpensesChartWebPart : ChartWebPart
{
public ProjectExpensesChartWebPart()
{
}
protected override void CreateChildControls()
{
base.CreateChildControls();
}
}
}
Elements.xml:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/" >
<Module Name="ProjectExpensesChartWebPart" List="113" Url="_catalogs/wp">
<File Path="ProjectExpensesChartWebPart\ProjectExpensesChartWebPart.webpart"
Url="ProjectExpensesChartWebPart.webpart"
Type="GhostableInLibrary">
<Property Name="Group" Value="CBS" />
</File>
</Module>
</Elements>
La distribuzione del webpart e aggiungendolo a un sito non è un problema, ma quando provo a configurare il webpart, getta un esibirci:
Tipo: SerializationException Messaggio:. Il costruttore che è necessario per la deserializzazione di un oggetto del tipo "[...] ProjectExpensesChartWebPart" non è stato trovato *
* Nota: traduzione, dal momento che ho la versione tedesca di SP installato. Originale:. "Der für die Deserialisierung eines Objekts mit dem Typ "[...] ProjectExpensesChartWebPart". Erforderliche Konstruktor wurde nicht gefunden"
Spero che qualcuno ha un indizio, cosa c'è di sbagliato qui, o può almeno mi punto nella giusta direzione.
Inoltre, il Stacktrace:
bei System.Runtime.Serialization.ObjectManager.CompleteISerializableObject (Object obj, informazioni SerializationInfo, context StreamingContext) bei System.Runtime.Serialization.ObjectManager.FixupSpecialObject (ObjectHolder titolare)
bei System.Runtime.Serialization.ObjectManager.DoFixups () bei System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize (gestore HeaderHandler, __BinaryParser serParser, booleano FVerificare, booleano isCrossAppDomain, IMethodCallMessage methodCallMessage) bei System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize (Stream serializationStream, gestore HeaderHandler, booleano FVerificare, booleano isCrossAppDomain, IMethodCallMessage methodCallMessage) bei System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize (Stream serializationStream) bei Microsoft.Office.Server.Internal.Charting.Utilities.ChartAdminPageBase.get_currentWorkingSet () bei Microsoft.Office.Server.Internal.Charting.Utilities.ChartAdminPageBase.FetchFromCurrentWorkingSet (String key) bei Microsoft.Office.Server.Internal.Charting.UI.WizardConnectToDataPage.LoadModel () bei Microsoft.Office.Server.Internal.Charting.UI.WizardConnectToDataPage.OnLoad (EventArgs) bei System.Web.UI.Control.LoadRecursive () bei System.Web.UI.Page.ProcessRequestMain (booleano includeStagesBeforeAsyncPoint, booleano includeStagesAfterAsyncPoint)
Soluzione
Credo che bisogna aggiungere il costruttore ProjectExpensesChartWebPart (info SerializationInfo, context StreamingContext) addintionally al costruttore di default.