Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

Re: "Unexpected data!" expection bubbles to the top and crashes program

Please set Session.SessionLogPath and Session.DebugLogPath and post both logs once the problem occurs.
Samy110

"Unexpected data!" expection bubbles to the top and crashes program

We are currently using WinSCP Version 5.21.5 via .NET Assembly and observing a tedious issue on one system in particular.

The following exception is sometimes thrown by the WinSCP .NET Assembly:
System.InvalidOperationException: Unexpected data  at 

WinSCP.ExeSessionProcess.ProcessTransferOutEvent(ConsoleTransferEventStruct e) at
WinSCP.ExeSessionProcess.ProcessEvent()  at
WinSCP.ExeSessionProcess.ProcessEvents()   at
System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)   at
System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)  at
System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

Normally exceptions are not a problem. But because this one is thrown in a thread managed entirely by the WinSCP .NET Assembly, it is very difficult to catch and crashes our program that spawned WinSCP in the first place.

We have session logs enabled, but unfortunately haven't found any matching timestamps (yet) between our crash logs and the WinSCP logs. So we don't know what exactly is causing WinSCP to throw this exception.

Looking through the WinSCPnet project, I would suggest to catch the exception and return a useful error back to the caller of the WinSCP .NET Assembly:
// Try... Catch.. here?
_thread = new Thread(ProcessEvents)
{
   IsBackground = true
};
 _thread.Start();

File "ExeSessionProcess.cs" Line 214

Thanks for your help.
- Sam