Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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".

Elements.xml:

<?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" />
      </File>
    </Module>
</Elements>

.webpart:

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

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";
        _table.Columns.Add(col);

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

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?

share|improve this question
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.