dbLinqDataSource.ContextCreating - Object does not match target type.

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
Post Reply
alekas
Posts: 4
Joined: Thu 14 Feb 2013 19:34

dbLinqDataSource.ContextCreating - Object does not match target type.

Post by alekas » Sun 03 Mar 2013 21:34

I use ContextCreating event to return Context:

protected void ds_ContextCreating(object sender, LinqDataSourceContextEventArgs e)
{
e.ObjectInstance = DC; //DC is Devart.Data.Linq.DataContext type
}

When it runs I get an error:
Object does not match target type.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Reflection.TargetException: Object does not match target type.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[TargetException: Object does not match target type.]
System.Reflection.RuntimeMethodInfo.CheckConsistency(Object target) +10774111
System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +115
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +54
System.Reflection.RuntimePropertyInfo.GetValue(Object obj, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture) +61
System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[] index) +19
System.Web.UI.WebControls.LinqDataSourceView.CreateContextAndTable(DataSourceOperation operation) +799
System.Web.UI.WebControls.LinqDataSourceView.CreateContextAndTableForSelect() +137
System.Web.UI.WebControls.LinqDataSourceView.CreateContext(DataSourceOperation operation) +12
System.Web.UI.WebControls.ContextDataSourceView.GetSource(QueryContext context) +20
System.Web.UI.WebControls.LinqDataSourceView.GetSource(QueryContext context) +325
System.Web.UI.WebControls.LinqDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +63
System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +21
DevExpress.Web.ASPxClasses.Internal.DataHelper.PerformSelect() +232
DevExpress.Web.ASPxClasses.Internal.DataContainer.PerformSelect() +120
DevExpress.Web.ASPxClasses.ASPxDataWebControlBase.DataBindCore() +49
DevExpress.Web.ASPxClasses.ASPxDataWebControlBase.DataBindInternal() +215
DevExpress.Web.ASPxClasses.ASPxWebControl.DataBind() +51
DevExpress.Web.ASPxEditors.ASPxComboBox.DataBind() +44
DevExpress.Web.ASPxClasses.Internal.DataHelperBase.EnsureDataBound(Boolean ensureChildControls) +114
DevExpress.Web.ASPxClasses.Internal.DataHelperBase.EnsureDataBound() +34
DevExpress.Web.ASPxClasses.Internal.DataContainer.EnsureDataBound() +120
DevExpress.Web.ASPxClasses.ASPxDataWebControlBase.OnPreRender(EventArgs e) +52
System.Web.UI.Control.PreRenderRecursiveInternal() +83
System.Web.UI.Control.PreRenderRecursiveInternal() +168


Is there anything I am doing wrong there?

Thanks,
Alex

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Re: dbLinqDataSource.ContextCreating - Object does not match target type.

Post by StanislavK » Mon 04 Mar 2013 17:47

Could you please describe this scenario in more details? In particular, please specify how the DataContext and DbLinqDataSource objects are created.

If possible, send us a sample application, so that we are able to analyze the situation in more details.

Post Reply