My Sharepoint project contains a visual Webpart which retrieves data and works fine. In addition to that, I want to display some Chart webparts which visualize this data. In order to do so, i added a new item to the project (WebPart; not Visual Webpart) in which I create a datatable, add data to it and a ConnectionPoint.

the problem occurs after deployment, when i try to add this webpart to the page. There is simply an alert "Webpart cannot be importet".


<?xml version="1.0" encoding="utf-8"?>
  <Elements xmlns="http://schemas.microsoft.com/sharepoint/" >
    <Module Name="KategorieChartDataProvider" List="113" Url="_catalogs/wp">
      <File Path="KategorieChartDataProvider\KategorieChartDataProvider.webpart" Url="KategorieChartDataProvider.webpart" Type="GhostableInLibrary">
        <Property Name="Group" Value="Custom" />


<?xml version="1.0" encoding="utf-8"?>
  <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
      <type name="TestProjekt.KategorieChartDataProvider.KategorieChartDataProvider, $SharePoint.Project.AssemblyFullName$" />
        <property name="Title" type="string">KategorieChartDataProvider</property>
        <property name="Description" type="string">Description will follow</property>

Is there an obvious error I am missing?

Kind regards

/edit: I am using WSP builder to deploy if that information is useful to you /edit2: I found a partial solution. The error was insinde the webpartcode. I had the following code in the constructor for the KategorieChartDataProvider class.

DataTable _table = new DataTable();

        DataColumn col = new DataColumn();
        col.DataType = typeof(string);
        col.ColumnName = "Kategorie";

        col = new DataColumn();
        col.DataType = typeof(int);
        col.ColumnName = "Value";
        foreach (var item in repo.GetAllCategories())
            DataRow row = new DataRow();
            row["Kategorie"] = item._name;
            row["Value"] = item._val;

This bit of code is now located in the OnInit method. However, if I use this webpart now (I can add it to the page) I am getting a Null Reference Exception.

[NullReferenceException: Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.]
TestProjekt.KategorieChartDataProvider.KategorieChartDataProvider.GetTableData(TableCallback callback) +68
Microsoft.Office.Server.WebControls.Charting.WebPart.SetTableProvider(IWebPartTable provider) +294

[TargetInvocationException: Ein Aufrufziel hat einen Ausnahmefehler verursacht.] System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) +0
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) +1255
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +38 System.Web.UI.WebControls.WebParts.ConsumerConnectionPoint.SetObject(Control control, Object data) +98
Microsoft.SharePoint.WebPartPages.SPWebPartConnection.Activate() +1980 Microsoft.SharePoint.WebPartPages.SPWebPartManager.ActivateConnections() +439 System.Web.UI.WebControls.WebParts.WebPartManager.OnPageLoadComplete(Object sender, EventArgs e) +70 System.EventHandler.Invoke(Object sender, EventArgs e) +0 System.Web.UI.Page.OnLoadComplete(EventArgs e) +11057518 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3160

any ideas on this one?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.