1

I'm using WebSync in a .NET application where a client is making calls to connect, subscribe, etc to WebSync. Somewhere along the execution of the code (It's a big app), I get the gray box popup saying the above error message. Because this is a big app, how can I find where in the application this is occurring? The problem is that this application has a lot of threads.

Does this message mean there is a problem in FM.dll (WebSync) or does it mean that I'm missing something in my code that should catch this exception. If the latter, how do I find where in my code this may occur?

Thanks!

Here is the Call Stack to my error. How can I tell if this is an error on my part or if the problem is inside FM.dll (WebSync)?

FM.dll!FM.AsyncException.AsyncThrow.AnonymousMethod__0(object unused) + 0x47 bytes
mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) + 0x285 bytes mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) + 0x9 bytes
mscorlib.dll!System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() + 0x6f bytes mscorlib.dll!System.Threading.ThreadPoolWorkQueue.Dispatch() + 0x1ea bytes
[Native to Managed Transition]
[Appdomain Transition]
[Native to Managed Transition]

Ray
  • 4,679
  • 10
  • 46
  • 92
  • Have you tried debugging the app? I don't think we have enough information here to help you. – Sven Grosen Jan 31 '14 at 22:13
  • I tried debugging but I get confused when I press F5 to continue and I notice other threads come into play. It's hard to finally reach the point where the above error occurs. I tried Josh's suggestion. I'll post the call stack. – Ray Feb 03 '14 at 19:17

2 Answers2

1

If you have 'Break on All Exceptions' turned on then once you start the debugger, when the exception is thrown, you'll be able to see and navigate the stack trace. This should give you an idea of the path the code is on leading up to the exception. You can also interrogate the exception to check to see if the InnerException property has been set. From that information you should be able to determine what is causing the issue. If not post more details from the information you gather and you can get more help.

Instruction for setting up Visual Studio to break on all exceptions: http://msdn.microsoft.com/en-us/library/d14azbfh.aspx

Josh
  • 1,724
  • 13
  • 15
  • I added the call stack but none of my code appears in it. There are some transitions in there though. – Ray Feb 04 '14 at 15:48
  • What do you mean by transitions? – Josh Feb 04 '14 at 19:07
  • If you look at the call stack that I added, there are lines that say Native to Managed Transition. – Ray Feb 07 '14 at 01:33
  • I've been out of town Ray, sorry for the delay. It looks like the problem is inside the FM.dll. The easiest solution is to grab the source project for the FM.dll, include it in your dev project and then debug from there. That way you can break on the exact line causing the exception. – Josh Feb 22 '14 at 21:54
0

In FM libraries, AsyncException.AsyncThrow is used when an exception is thrown in an async callback. Try wrapping your FM callback code in try/catch blocks to catch exceptions, e.g.:

client.Connect(new ConnectArgs
{
    OnSuccess = (e) =>
    {
        try
        {
            // your code
        }
        catch (Exception ex)
        {
            // handle exception
        }
    }
});

If you don't wrap your callback code in a try/catch block, then the FM library will push the exception to a thread where it will be fail loudly rather than swallow/hide it.

Anton
  • 4,554
  • 2
  • 37
  • 60