SerializationException - Can't find constructor for an object (custom Chart Web Part)

sharepoint.stackexchange https://sharepoint.stackexchange.com/questions/13641

  •  16-10-2019
  •  | 
  •  

Pergunta

For a project, I've created a web-part which derives from the ChartWebPart class (in order to set the data-source relatively).

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>

Deploying the web-part and adding it to a site is no problem, but when I try to configure the webpart, it throws an exeption:

Type: SerializationException Message: The constructor which is needed for the deserialization of an object of the type "[...].ProjectExpensesChartWebPart" couldn't be found.*

*note: translation, since I have the german version of SP installed. Original: "Der für die Deserialisierung eines Objekts mit dem Typ "[...].ProjectExpensesChartWebPart" erforderliche Konstruktor wurde nicht gefunden."

I hope that someone has a clue, what's wrong here, or can at least point me in the right direction.

also, the Stacktrace:

bei System.Runtime.Serialization.ObjectManager.CompleteISerializableObject(Object obj, SerializationInfo info, StreamingContext context) bei System.Runtime.Serialization.ObjectManager.FixupSpecialObject(ObjectHolder holder)
bei System.Runtime.Serialization.ObjectManager.DoFixups() bei System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage) bei System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean 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 e) bei System.Web.UI.Control.LoadRecursive() bei System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Foi útil?

Solução

I think you have to add the constructor ProjectExpensesChartWebPart(SerializationInfo info, StreamingContext context) addintionally to the default constructor.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a sharepoint.stackexchange
scroll top