TargetException raising javsacript event from worker thread

G

Guest

Hi,

I am having an issue which apparently (according to the word of google) a
few other people have run into but found no satisfactory answer. I have a
winforms user control hosted in IE which uploads files to a web server
asyncronously. Once the file is uploaded or an exception is thrown, my c#
callback fires, which in turn raises an event which is supposed to call a
javascript function to fire.

However, when the event is raised, I get a TargetException ("Object does not
match target type") with reference to my javascript handler - this event when
raised from outside of the callback works fine.

Coudl any body give any hints as to what might be going on or how to work
around it? I have tried different methods of doing the async callback
(BackgroundWorker, async delegate) and they both exhibit the same behaviour
when raising the event.

Any help would be much appreciated!
 
J

Jeffrey Tan[MSFT]

Hi willholley,

Thanks for your post.

First, I want to confirm that the exception is caused by the code invoking
the javascript handler(included in the event handler) or by the code firing
the event(included in the callback)? If we commented the code firing the
javascript handler, does this exception occur?

Second, can you catch this exception and show the full call stack of this
exception? Then we can get more context information regarding the exception.

At last, is it possible for you to provide a little demo project to help us
reproduce the problem? This is should be very useful for the understanding
and researching.

Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
G

Guest

Hi Jeff,

Thanks for the swift reply!

The exception is indeed caused by the code invoking the javascript handler.
Here are the details of the exception:

Message="Object does not match target type."
Source="mscorlib"
StackTrace:
at System.RuntimeType.InvokeDispMethod(String name, BindingFlags
invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32
culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags
bindingFlags, Binder binder, Object target, Object[] providedArgs,
ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at System.RuntimeType.ForwardCallToInvokeMember(String memberName,
BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData&
msgData)
at
BluewireTechnologies.Epro.UI.WinUserControls.IO.IEproFileUploadControlCOMEvents.UploadComplete(String sCtrlId, String sFileName)
at
BluewireTechnologies.Epro.UI.WinUserControls.IO.FileUploadControl.DoUploadComplete(Boolean success)
at
BluewireTechnologies.Epro.UI.WinUserControls.IO.FileUploadControl.DoUploadCallback(IAsyncResult ar)
at
System.Runtime.Remoting.Messaging.AsyncResult.SyncProcessMessage(IMessage msg)
at
System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage msg, IMessageSink replySink)
at
System.Runtime.Remoting.Proxies.AgileAsyncWorkerItem.ThreadPoolCallBack(Object o)
at
System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at
System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext
executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
at
System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(Object state).

I'll work on getting a demo project for you asap.



"Jeffrey Tan[MSFT]" said:
Hi willholley,

Thanks for your post.

First, I want to confirm that the exception is caused by the code invoking
the javascript handler(included in the event handler) or by the code firing
the event(included in the callback)? If we commented the code firing the
javascript handler, does this exception occur?

Second, can you catch this exception and show the full call stack of this
exception? Then we can get more context information regarding the exception.

At last, is it possible for you to provide a little demo project to help us
reproduce the problem? This is should be very useful for the understanding
and researching.

Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
J

Jeffrey Tan[MSFT]

Hi willholley,

Thanks for your feedback.

For this issue, it seems that it is a COM interop issue. First, let's try
to force it work on the development machine.

For your control library, can you try to trun on "register for COM interop"
option in the VS.net2003 project setting? This option is listed under
"Configuration Properties"-> "Build" -> "Outputs" -> "Register for COM
interop"

Let's see if turning on this option will resolve this problem. I will wait
for your test feedback. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top