Targetinvocationexception

  • Thread starter Thread starter Paul
  • Start date Start date
P

Paul

Hi, I have a dropdown box bound to a data object. In the code below I am
trying to bind this dropdown box to a different dataobject called
ObjDtaSceSystemBySystemType but get the error (Target invocation exception)
when I try to bind the dropdown box to the new dataobject. Any IDEAS!

ObjDtaSceSystemBySystemType.SelectParameters["SystemTypeID"].DefaultValue =
Convert.ToString(drdwnSystemtype.SelectedValue);
ObjDtaSceSystemBySystemType.DataBind();
drdwnSystem.Items.Clear();
drdwnSystem.DataSourceID = "ObjDtaSceSystemBySystemType";
drdwnSystem.DataBind();

Below is the detailed error information.

System.Reflection.TargetInvocationException was unhandled by user code
Message="Exception has been thrown by the target of an invocation."
Source="mscorlib"
StackTrace:
at System.RuntimeMethodHandle._InvokeMethodFast(Object target,
Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes,
RuntimeTypeHandle typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(Object target,
Object[] arguments, Signature sig, MethodAttributes methodAttributes,
RuntimeTypeHandle typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj,
BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo
culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj,
BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo
culture)
at
System.Web.UI.WebControls.ObjectDataSourceView.InvokeMethod(ObjectDataSourceMethod method, Boolean disposeInstance, Object& instance)
at
System.Web.UI.WebControls.ObjectDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments)
at System.Web.UI.WebControls.ListControl.OnDataBinding(EventArgs e)
at System.Web.UI.WebControls.ListControl.PerformSelect()
at System.Web.UI.WebControls.BaseDataBoundControl.DataBind()
at InspectionsNew.drdwnSystemtype_SelectedIndexChanged(Object sender,
EventArgs e) in
c:\Inetpub\wwwroot\ALLQSISREALDATA\SQSIS\frmInspectionsNew.aspx.cs:line 235
at
System.Web.UI.WebControls.ListControl.OnSelectedIndexChanged(EventArgs e)
at System.Web.UI.WebControls.DropDownList.RaisePostDataChangedEvent()
at
System.Web.UI.WebControls.DropDownList.System.Web.UI.IPostBackDataHandler.RaisePostDataChangedEvent()
at System.Web.UI.Page.RaiseChangedEvents()
at System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
 
As if the method you have specified to be called for the ObjectdataSource
would throw an error....have you confirmed that calling this method as
stand-alone works? And how's he type that ODS instantiates? (see:
http://forum.springframework.net/showthread.php?t=1377 for discussion in bit
similar case as yours)

--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net

Paul said:
Hi, I have a dropdown box bound to a data object. In the code below I am
trying to bind this dropdown box to a different dataobject called
ObjDtaSceSystemBySystemType but get the error (Target invocation
exception)
when I try to bind the dropdown box to the new dataobject. Any IDEAS!

ObjDtaSceSystemBySystemType.SelectParameters["SystemTypeID"].DefaultValue
=
Convert.ToString(drdwnSystemtype.SelectedValue);
ObjDtaSceSystemBySystemType.DataBind();
drdwnSystem.Items.Clear();
drdwnSystem.DataSourceID = "ObjDtaSceSystemBySystemType";
drdwnSystem.DataBind();

Below is the detailed error information.

System.Reflection.TargetInvocationException was unhandled by user code
Message="Exception has been thrown by the target of an invocation."
Source="mscorlib"
StackTrace:
at System.RuntimeMethodHandle._InvokeMethodFast(Object target,
Object[] arguments, SignatureStruct& sig, MethodAttributes
methodAttributes,
RuntimeTypeHandle typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(Object target,
Object[] arguments, Signature sig, MethodAttributes methodAttributes,
RuntimeTypeHandle typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj,
BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo
culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj,
BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo
culture)
at
System.Web.UI.WebControls.ObjectDataSourceView.InvokeMethod(ObjectDataSourceMethod
method, Boolean disposeInstance, Object& instance)
at
System.Web.UI.WebControls.ObjectDataSourceView.ExecuteSelect(DataSourceSelectArguments
arguments)
at System.Web.UI.WebControls.ListControl.OnDataBinding(EventArgs e)
at System.Web.UI.WebControls.ListControl.PerformSelect()
at System.Web.UI.WebControls.BaseDataBoundControl.DataBind()
at InspectionsNew.drdwnSystemtype_SelectedIndexChanged(Object
sender,
EventArgs e) in
c:\Inetpub\wwwroot\ALLQSISREALDATA\SQSIS\frmInspectionsNew.aspx.cs:line
235
at
System.Web.UI.WebControls.ListControl.OnSelectedIndexChanged(EventArgs e)
at
System.Web.UI.WebControls.DropDownList.RaisePostDataChangedEvent()
at
System.Web.UI.WebControls.DropDownList.System.Web.UI.IPostBackDataHandler.RaisePostDataChangedEvent()
at System.Web.UI.Page.RaiseChangedEvents()
at System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
 
Thanks for the response. I was able to get it to work, first set the
datasourceid = null then just set the datasource to the new object and then
the databind. After this I still had the same error, but noticed that the
stored procedure did not have execute permissions, after changing this it
works!
--
Paul G
Software engineer.


Teemu Keiski said:
As if the method you have specified to be called for the ObjectdataSource
would throw an error....have you confirmed that calling this method as
stand-alone works? And how's he type that ODS instantiates? (see:
http://forum.springframework.net/showthread.php?t=1377 for discussion in bit
similar case as yours)

--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net

Paul said:
Hi, I have a dropdown box bound to a data object. In the code below I am
trying to bind this dropdown box to a different dataobject called
ObjDtaSceSystemBySystemType but get the error (Target invocation
exception)
when I try to bind the dropdown box to the new dataobject. Any IDEAS!

ObjDtaSceSystemBySystemType.SelectParameters["SystemTypeID"].DefaultValue
=
Convert.ToString(drdwnSystemtype.SelectedValue);
ObjDtaSceSystemBySystemType.DataBind();
drdwnSystem.Items.Clear();
drdwnSystem.DataSourceID = "ObjDtaSceSystemBySystemType";
drdwnSystem.DataBind();

Below is the detailed error information.

System.Reflection.TargetInvocationException was unhandled by user code
Message="Exception has been thrown by the target of an invocation."
Source="mscorlib"
StackTrace:
at System.RuntimeMethodHandle._InvokeMethodFast(Object target,
Object[] arguments, SignatureStruct& sig, MethodAttributes
methodAttributes,
RuntimeTypeHandle typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(Object target,
Object[] arguments, Signature sig, MethodAttributes methodAttributes,
RuntimeTypeHandle typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj,
BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo
culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj,
BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo
culture)
at
System.Web.UI.WebControls.ObjectDataSourceView.InvokeMethod(ObjectDataSourceMethod
method, Boolean disposeInstance, Object& instance)
at
System.Web.UI.WebControls.ObjectDataSourceView.ExecuteSelect(DataSourceSelectArguments
arguments)
at System.Web.UI.WebControls.ListControl.OnDataBinding(EventArgs e)
at System.Web.UI.WebControls.ListControl.PerformSelect()
at System.Web.UI.WebControls.BaseDataBoundControl.DataBind()
at InspectionsNew.drdwnSystemtype_SelectedIndexChanged(Object
sender,
EventArgs e) in
c:\Inetpub\wwwroot\ALLQSISREALDATA\SQSIS\frmInspectionsNew.aspx.cs:line
235
at
System.Web.UI.WebControls.ListControl.OnSelectedIndexChanged(EventArgs e)
at
System.Web.UI.WebControls.DropDownList.RaisePostDataChangedEvent()
at
System.Web.UI.WebControls.DropDownList.System.Web.UI.IPostBackDataHandler.RaisePostDataChangedEvent()
at System.Web.UI.Page.RaiseChangedEvents()
at System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
 
Back
Top