Proud To Be Pakistanis!
Welcome to weblogs.com.pk Sign in | Join | Help
in Search



While calling member functions through BeginInvoke you can get a System.Reflection.TargetParameterCountException. In my case I wrote the following line:
Me.BeginInvoke(New dlgOneObj(AddressOf SearchOperationEnd), Nothing)

Where: Me is Form1, dlgOneObj is a delegate (naturally).
The definition of SearchOperationEnd is:
Public Sub SearchOperationEnd(ByVal obj As Object)

I thought passing the Nothing in BeginInvoke should have worked but it didnt. Now the worst part of all this is that the place where the TargetParameterCountException occurs gives, us ignorant developers, no clue of what might have happened. Well there is a clue; the exception is from System.Reflection namespace so you know you messed up with some dynamic stuff. In my case the exception was raised in Main method where I self wrote Application.Run( new frmABC()). Now why the debugger landed in the shared Main method's Application.Run line when actually the exception is due to the statement written in a MySearchBase form that was opened from the frmABC? I dont know. So anyway I traced my beginInvoke statements which I had just written before this exception showed up and changed the call to:
Me.BeginInvoke(New dlgOneObj(AddressOf SearchOperationEnd), New Object () {Nothing})

Now it works just fine.
Published Monday, April 10, 2006 6:58 PM by abubakar


No Comments
Anonymous comments are disabled

This Blog



No tags have been created or used yet.
Powered by Community Server (Personal Edition), by Telligent Systems