I'm getting an error in a new unfamiliar area to me, SharePoint development. I'm trying to debug my solution via Visual Studio 2012 and I get the following error as recorded in the EventLog:
Exception information:
Exception type: FileLoadException Exception message: The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
The error is seen within the .ascx.g.cs for my control, in a @__BuildControlTree method. Unfortunately it doesn't tell me the name of the assembly, so I'm not sure where the error lies. The stack trace reported is:
Stack trace:
at MI.VWP.Chart.Chart.CreateChildControls() at System.Web.UI.Control.EnsureChildControls() at System.Web.UI.WebControls.WebParts.Part.get_Controls() at System.Web.UI.Control.AddParsedSubObject(Object obj) at Microsoft.SharePoint.WebPartPages.WebPart.AddParsedSubObject(Object obj) at MooDInternational.VisualWebParts.Chart.Chart.__BuildControlTree(Chart __ctrl) at MooDInternational.VisualWebParts.Chart.Chart.InitializeControl() at MooDInternational.VisualWebParts.Chart.Chart.OnInit(EventArgs e) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.AddedControl(Control control, Int32 index) at System.Web.UI.WebControls.WebParts.WebPartManager.WebPartManagerControlCollection.AddWebPartHelper(WebPart webPart) at System.Web.UI.WebControls.WebParts.WebPartManager.WebPartManagerControlCollection.AddWebPart(WebPart webPart) at System.Web.UI.WebControls.WebParts.WebPartManagerInternals.AddWebPart(WebPart webPart) at Microsoft.SharePoint.WebPartPages.SPWebPartManager.AddWebPartWithRetry(WebPart webPart) at Microsoft.SharePoint.WebPartPages.SPWebPartManager.CreateWebPartsFromRowSetData(Boolean onlyInitializeClosedWebParts) at Microsoft.SharePoint.WebPartPages.SPWebPartManager.LoadWebParts()
at Microsoft.SharePoint.WebPartPages.SPWebPartManager.OnPageInitComplete(Object sender, EventArgs e) at System.EventHandler.Invoke(Object sender, EventArgs e) at System.Web.UI.Page.OnInitComplete(EventArgs e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
I don't however get a call to that method if I attempt to set a breakpoint there. I've tried looking at fusionlog but get the following which I don't think helps...
* Assembly Binder Log Entry (13/09/2012 @ 14:16:15) *
The operation was successful. Bind result: hr = 0x0. The operation completed successfully.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll Running under executable C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions\Microsoft\SharePoint\vssphost4.exe --- A detailed error log follows.
=== Pre-bind state information === LOG: User = **.***** LOG: DisplayName = Microsoft.Build.Framework, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a (Fully-specified) LOG: Appbase = file:///C:/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/IDE/Extensions/Microsoft/SharePoint/ LOG: Initial PrivatePath = C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions\Microsoft\SharePoint\VstspCache10724 LOG: Dynamic Base = NULL LOG: Cache Base = NULL LOG: AppName = NULL Calling assembly : (Unknown). LOG: This bind starts in default load context. LOG: Using application configuration file: C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions\Microsoft\SharePoint\vssphost4.exe.Config LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v2.0.50727\config\machine.config. LOG: Binding succeeds. Returns assembly from C:\Windows\assembly\GAC_MSIL\Microsoft.Build.Framework\2.0.0.0__b03f5f7f11d50a3a\Microsoft.Build.Framework.dll. LOG: Assembly is loaded in default load context.
Can anyone make any suggestions on how I might resolve this issue?
EDIT
Using Reflector I managed to debug into the generated @_BuildControl method a little, and discover a call to AddParsedSubject(object child) which is a virtual method on a control.
Adding the following code:
protected override void AddParsedSubObject(object obj)
{
System.Web.UI.Control child = obj as System.Web.UI.Control;
if (child != null)
{
try
{
base.AddParsedSubObject(obj);
System.Diagnostics.Trace.WriteLine("Added " + child.ToString());
}
catch (Exception ex)
{
System.Diagnostics.Trace.WriteLine("Error with " + child.ToString() + " : " + ex.ToString());
}
}
}
This told me that the control causing the issue was a DevExpress.XtraCharts.Web.WebChartControl, so know I've tracked the assembly down to one of the DevExpress ones, not 100% sure which and not yet sure how to fix it.
In asp.net this kind of errors means that old references are not been replaced in bin or temp asp.net folder. I would clean those folders an rebuild my project if i was you..
User contributions licensed under CC BY-SA 3.0