System.Runtime.InteropServices.COMException in Winrt Package - windows-8

I am developing an app in Windows 8 (XAML).
The application runs fine on local machine, however when I create a package in Release Mode and test the app, it crashes.
I saw the application log in my computer and found this error
Application: MyApp.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Runtime.InteropServices.COMException
Stack:
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Threading.WinRTSynchronizationContext+Invoker.b__0(System.Object)
at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(System.Object)
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()

Related

calling a method in a smali file using ApplicationContext

I want to call a method using p0 ApplicationContext:Landroid/content/Context.
How can I get the ApplicationContext for the class?
I tried calling my method from the init method of the class in order to copy p0, but android failed to verify the class with this.
Any ideas? I will provide more detail if required.
#JesusFreke : More info
1 EDITED CRASH
10-06 15:43:48.081 14308 14557 E AndroidRuntime: FATAL EXCEPTION: WFSync
10-06 15:43:48.081 14308 14557 E AndroidRuntime: Process: com.zynga.words3, PID: 14308
10-06 15:43:48.081 14308 14557 E AndroidRuntime: java.lang.VerifyError: Verifier rejected class com.zynga.wfframework.appmodel.game.GameCenter$6: void com.zynga.wfframework.appmodel.game.GameCenter$6.<init>(com.zynga.wfframework.appmodel.game.GameCenter, android.content.Context, com.zynga.wfframework.appmodel.AppModelCallback, java.util.Date, long, java.util.Date, long, com.zynga.wfframework.remoteservice.IRemoteService$PollType, com.zynga.wfframework.appmodel.sync.SyncService$SyncServicePollType, android.content.Intent, int) failed to verify: void com.zynga.wfframework.appmodel.game.GameCenter$6.<init>(com.zynga.wfframework.appmodel.game.GameCenter, android.content.Context, com.zynga.wfframework.appmodel.AppModelCallback, java.util.Date, long, java.util.Date, long, com.zynga.wfframework.remoteservice.IRemoteService$PollType, com.zynga.wfframework.appmodel.sync.SyncService$SyncServicePollType, android.content.Intent, int):
[0x41] 'this' arg must be initialized
(declaration of 'com.zynga.wfframework.appmodel.game.GameCenter$6' appears in /data/app/com.zynga.words3-2/base.apk:classes3.dex)
10-06 15:43:48.081 14308 14557 E AndroidRuntime: at com.zynga.wfframework.appmodel.game.GameCenter.refreshState(SourceFile:1201)
10-06 15:43:48.081 14308 14557 E AndroidRuntime: at com.zynga.wfframework.appmodel.game.GameCenter.refreshState(SourceFile:1144)
10-06 15:43:48.081 14308 14557 E AndroidRuntime: at com.zynga.wfframework.appmodel.sync.SyncService$1.run(SourceFile:189)
10-06 15:43:48.081 14308 14557 E AndroidRuntime: at java.lang.Thread.run(Thread.java:761)
2 PARTIAL CODE
.method constructor <init>(Lcom/zynga/wfframework/appmodel/game/GameCenter;Landroid/content/Context;Lcom/zynga/wfframework/appmodel/AppModelCallback;Ljava/util/Date;JLjava/util/Date;JLcom/zynga/wfframework/remoteservice/IRemoteService$PollType;Lcom/zynga/wfframework/appmodel/sync/SyncService$SyncServicePollType;Landroid/content/Intent;I)V
.registers 16
...
##41
#v0=(Reference,Lcom/zynga/wfframework/remoteservice/RemoteServiceSyncResult;);v1=(Null);p0=(UninitThis,Lcom/zynga/wfframework/appmodel/game/GameCenter$6;);
invoke-virtual {p0, v1, v0}, Lcom/zynga/wfframework/appmodel/game/GameCenter$6;->onPostExecute(ILcom/zynga/wfframework/remoteservice/RemoteServiceSyncResult;)V
Why is p0 not initialised? What can I do to catch it initialised?
Hope you can help. By the way, I fixed the problem in another way, but this relies on an error method in the class being called. I would prefer to find another solution.
In a constructor, the this argument (p0) starts out as uninitialized, and it can't be used until it has been initialized. You must call the superclass's <init> method to initialize it.
e.g. if the super class is Lcom/some/superclass;, and it has a no-args constructor, you would need to add
invoke-direct {p0}, Lcom/some/superclass;-><init>()V
at some point before you try to use p0.
Assuming you're starting out with a working method to begin with, the constructor should already have such an instruction. In which case, you just need to move your method call after it.

Manage Nuget Packages crashes VS2017

I get Visual Studio crashing everytime I add a Nuget Reference. It feels like a BUG.
It was reported to the Developer Community (beta) site: https://developercommunity.visualstudio.com/content/problem/6782/manage-nuget-packages-crashes-vs2017rc.html
It states it was fixed, so the exact root cause of this must be different:
The problem looks like it existed back in 2015 but no answers: Nuget Package Manager crashes when clicking "Manage nuget packages for solution" Visual Studio 2015
Its so annoying I have to use the Console to install packages or edit the packages.config file manually and then restore the packages. Not Happy - does anyone have a solution?
Specs
Win7 x64
Microsoft Visual Studio Enterprise 2017
Version 15.2 (26430.6) Release
VisualStudio.15.Release/15.2.0+26430.6
Microsoft .NET Framework v 4.7.02053
Installed Version: Enterprise
.....
NuGet Package Manager 4.2.0
Event Log:
Application: devenv.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.UnauthorizedAccessException
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
at Microsoft.VisualStudio.Shell.Settings.ShellWritableSettingsStore.CreateCollection(String collectionPath)
at Microsoft.VisualStudio.PlatformUI.CategoryMRUItems.SaveItems(WritableSettingsStore store)
at Microsoft.VisualStudio.PlatformUI.MRUItemsStoreService.AddMRUItem(Guid& guidCategory, String lpszItem)
at Microsoft.VisualStudio.PlatformUI.MruItemsStoreServiceDecorator.AddMRUItem(Guid& guidCategory, String lpszItem)
at Microsoft.VisualStudio.Platform.WindowManagement.WindowSearchHost.Microsoft.VisualStudio.Platform.WindowManagement.IWindowSearchEventsHandler.OnAddMRUItem(String searchedText)
at Microsoft.VisualStudio.Platform.WindowManagement.WindowSearchDataSource.OnAddMRUItem(String searchedText)
at Microsoft.VisualStudio.PlatformUI.SearchControlDataSource.AddMRUItemAction(GelDependencyObject datasource, Object parameter)
at Microsoft.Internal.VisualStudio.PlatformUI.GelDependencyObject.Invoke(GelVerb descriptor, Object param)
at Microsoft.Internal.VisualStudio.PlatformUI.GelDependencyObject.Invoke(String verb, Object param)
at Microsoft.Internal.VisualStudio.PlatformUI.GelDependencyObject.Invoke(String verb, Object pvaIn, Object& pvaOut)
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32, IntPtr)
at Microsoft.Internal.VisualStudio.PlatformUI.Utilities.Invoke(Microsoft.VisualStudio.Shell.Interop.IVsUIDataSource, System.String, System.Object)
at Microsoft.VisualStudio.PlatformUI.SearchControl.AddToMRUItems(System.String)
at Microsoft.VisualStudio.PlatformUI.SearchControl.SearchBox_LostKeyboardFocus(System.Object, System.Windows.Input.KeyboardFocusChangedEventArgs)
at System.Windows.Input.KeyboardFocusChangedEventArgs.InvokeEventHandler(System.Delegate, System.Object)
at System.Windows.RoutedEventArgs.InvokeHandler(System.Delegate, System.Object)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(System.Object, System.Windows.RoutedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(System.Object, System.Windows.RoutedEventArgs, Boolean)
at System.Windows.UIElement.RaiseEventImpl(System.Windows.DependencyObject, System.Windows.RoutedEventArgs)
at System.Windows.UIElement.RaiseTrustedEvent(System.Windows.RoutedEventArgs)
at System.Windows.UIElement.RaiseEvent(System.Windows.RoutedEventArgs, Boolean)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputManager.ProcessInput(System.Windows.Input.InputEventArgs)
at System.Windows.Input.KeyboardDevice.ChangeFocus(System.Windows.DependencyObject, Int32)
at System.Windows.Input.KeyboardDevice.TryChangeFocus(System.Windows.DependencyObject, System.Windows.Input.IKeyboardInputProvider, Boolean, Boolean, Boolean)
at System.Windows.Input.KeyboardDevice.Focus(System.Windows.DependencyObject, Boolean, Boolean, Boolean)
at System.Windows.Input.KeyboardDevice.Focus(System.Windows.IInputElement)
at System.Windows.UIElement.Focus()
at System.Windows.Controls.ListBoxItem.HandleMouseButtonDown(System.Windows.Input.MouseButton)
at System.Windows.Controls.ListBoxItem.OnMouseLeftButtonDown(System.Windows.Input.MouseButtonEventArgs)
at System.Windows.UIElement.OnMouseLeftButtonDownThunk(System.Object, System.Windows.Input.MouseButtonEventArgs)
at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(System.Delegate, System.Object)
at System.Windows.RoutedEventArgs.InvokeHandler(System.Delegate, System.Object)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(System.Object, System.Windows.RoutedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(System.Object, System.Windows.RoutedEventArgs, Boolean)
at System.Windows.UIElement.ReRaiseEventAs(System.Windows.DependencyObject, System.Windows.RoutedEventArgs, System.Windows.RoutedEvent)
at System.Windows.UIElement.OnMouseDownThunk(System.Object, System.Windows.Input.MouseButtonEventArgs)
at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(System.Delegate, System.Object)
at System.Windows.RoutedEventArgs.InvokeHandler(System.Delegate, System.Object)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(System.Object, System.Windows.RoutedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(System.Object, System.Windows.RoutedEventArgs, Boolean)
at System.Windows.UIElement.RaiseEventImpl(System.Windows.DependencyObject, System.Windows.RoutedEventArgs)
at System.Windows.ContentElement.RaiseTrustedEvent(System.Windows.RoutedEventArgs)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputManager.ProcessInput(System.Windows.Input.InputEventArgs)
at System.Windows.Input.InputProviderSite.ReportInput(System.Windows.Input.InputReport)
at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr, System.Windows.Input.InputMode, Int32, System.Windows.Input.RawMouseActions, Int32, Int32, Int32)
at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr, MS.Internal.Interop.WindowMessage, IntPtr, IntPtr, Boolean ByRef)
at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)
Faulting application name: devenv.exe, version: 15.0.26430.6, time stamp: 0x5914d7fe
Faulting module name: KERNELBASE.dll, version: 6.1.7601.23807, time stamp: 0x5915f98e
Exception code: 0xe0434352
Fault offset: 0x0000c54f
Faulting process id: 0xf48
Faulting application start time: 0x01d2fb77b5f33dcc
Faulting application path: C:\Program Files x86\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\devenv.exe
Faulting module path: C:\WINDOWS\syswow64\KERNELBASE.dll
Report Id: f949036c-676b-11e7-8422-3417ebddc764
Error Handler Exception: System.ServiceModel.CommunicationException: There was an error reading from the pipe: Unrecognized error 109 (0x6d). ---> System.IO.IOException: The read operation failed, see inner exception. ---> System.ServiceModel.CommunicationException: There was an error reading from the pipe: Unrecognized error 109 (0x6d). ---> System.IO.PipeException: There was an error reading from the pipe: Unrecognized error 109 (0x6d).
at System.ServiceModel.Channels.PipeConnection.OnAsyncReadComplete(Boolean haveResult, Int32 error, Int32 numBytes)
--- End of inner exception stack trace ---
at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
at System.ServiceModel.Channels.ConnectionStream.EndRead(IAsyncResult asyncResult)
at System.Net.FixedSizeReader.ReadCallback(IAsyncResult transportResult)
--- End of inner exception stack trace ---
at System.Net.Security.NegotiateStream.EndRead(IAsyncResult asyncResult)
at System.ServiceModel.Channels.StreamConnection.EndRead()
--- End of inner exception stack trace ---
at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
at System.ServiceModel.Channels.TransportDuplexSessionChannel.EndTryReceive(IAsyncResult result, Message& message)
at System.ServiceModel.Dispatcher.DuplexChannelBinder.EndTryReceive(IAsyncResult result, RequestContext& requestContext)
at System.ServiceModel.Dispatcher.ErrorHandlingReceiver.EndTryReceive(IAsyncResult result, RequestContext& requestContext) \r\n at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
at System.ServiceModel.Channels.TransportDuplexSessionChannel.EndTryReceive(IAsyncResult result, Message& message)
at System.ServiceModel.Dispatcher.DuplexChannelBinder.EndTryReceive(IAsyncResult result, RequestContext& requestContext)
at System.ServiceModel.Dispatcher.ErrorHandlingReceiver.EndTryReceive(IAsyncResult result, RequestContext& requestContext)
I used SysInternals Process Monitor to find out that actual ACCESS_DENIED happens when VS attempts to RegCreateKey for a key:
\REGISTRY\A\{4B5F9AD2-BB8B-4CF8-9ACB-201C56F4D086}\Software\Microsoft\VisualStudio\15.0_05fc10d7\MRUItems\{00000000-0000-0000-0000-000000000000}\Items
This key appears to be stored in VS application hive file:
C:\Users\<user name>\AppData\Local\Microsoft\VisualStudio\15.0_05fc10d7\privateregistry.user.bin
I started regedit as admin, loaded hive file into regedit as described:
Launch RegEdit.exe
Select the Computer\HKEY_LOCAL_MACHINE node in the left-hand pane
Select the File | Load Hive... menu item, and load the privateregistry.user.bin
When prompted for a key name, just type in something like "VSRegHive"
This will load the data into a VSRegHive under the HKLM node
Create the 2 absent keys {00000000-0000-0000-0000-000000000000}\Items:
When finished select the VSRegHive and select
File | Unload Hive... , before exiting the RegEdit.exe utility, otherwise
VS will fail to start. Keeping the hive loaded in regedit creates some
sort of lock that prevents DevEnv.exe from launching.
With the 2 missing keys in place VS2017 doesn't crash in NuGet manager.
My VS2017 also crashes in NuGet package manager so I'm unable to add packages to project. Try start VS2017 as Administrator, mine lets me add packages this way, then I restart VS2017 as a normal user.

Visual Studio ends program instead of highlighting the error

Specifications
Visual Studio 2015 SP 1
.NET 4.0
VB.NET
I'm having a weird issue where my program doesn't stop the process and highlight the error point with the convenient popup that I'm used to. Instead the program dumps the error into the Output and I have to look through it to find where the issue is, what it is, and what it was.
This is getting kind of annoying and I wonder if this is a setup issue. My move to VS2015 was recent and I remade the project files so they would be a pure VS2015 project. The debugger was working at first, but it stopped a few days ago. This is the average message I get;
The thread 0x2044 has exited with code 0 (0x0).
'ProgramName.vshost.exe' (CLR v4.0.30319: ProgramName.vshost.exe): Loaded 'D:\Programming\ProgramName-Download\ProgramName\bin\Debug\ProgramName.exe'. Symbols loaded.
'ProgramName.vshost.exe' (CLR v4.0.30319: ProgramName.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.Remoting\v4.0_4.0.0.0__b77a5c561934e089\System.Runtime.Remoting.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ProgramName.vshost.exe' (CLR v4.0.30319: ProgramName.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ProgramName.vshost.exe' (CLR v4.0.30319: ProgramName.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_64\System.Transactions\v4.0_4.0.0.0__b77a5c561934e089\System.Transactions.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ProgramName.vshost.exe' (CLR v4.0.30319: ProgramName.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_64\System.EnterpriseServices\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ProgramName.vshost.exe' (CLR v4.0.30319: ProgramName.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_64\System.EnterpriseServices\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.Wrapper.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ProgramName.vshost.exe' (CLR v4.0.30319: ProgramName.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Numerics\v4.0_4.0.0.0__b77a5c561934e089\System.Numerics.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ProgramName.vshost.exe' (CLR v4.0.30319: ProgramName.vshost.exe): Loaded 'D:\Programming\ProgramName-Download\ProgramName\bin\Debug\ToolBoxCS.dll'. Symbols loaded.
The thread 0x213c has exited with code 0 (0x0).
Exception thrown: 'System.InvalidCastException' in ProgramName.exe
System.Transactions Critical: 0 : <TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Critical"><TraceIdentifier>http://msdn.microsoft.com/TraceCodes/System/ActivityTracing/2004/07/Reliability/Exception/Unhandled</TraceIdentifier><Description>Unhandled exception</Description><AppDomain>ProgramName.vshost.exe</AppDomain><Exception><ExceptionType>System.InvalidCastException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType><Message>Specified cast is not valid.</Message><StackTrace> at ProgramName.Interview.Load_Interview(Int32 Control, String Clientcode) in D:\Programming\ProgramName-Download\ProgramName\Class\Interview.vb:line 493
at ProgramName.frmInterview.frmInterview_Load(Object sender, EventArgs e) in D:\Programming\ProgramName-Download\ProgramName\Applications\frmInterview.vb:line 97
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message&amp; m)
at System.Windows.Forms.Control.WndProc(Message&amp; m)
at System.Windows.Forms.Form.WmShowWindow(Message&amp; m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)</StackTrace><ExceptionString>System.InvalidCastException: Specified cast is not valid.
at ProgramName.Interview.Load_Interview(Int32 Control, String Clientcode) in D:\Programming\ProgramName-Download\ProgramName\Class\Interview.vb:line 493
at ProgramName.frmInterview.frmInterview_Load(Object sender, EventArgs e) in D:\Programming\ProgramName-Download\ProgramName\Applications\frmInterview.vb:line 97
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message&amp; m)
at System.Windows.Forms.Control.WndProc(Message&amp; m)
at System.Windows.Forms.Form.WmShowWindow(Message&amp; m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)</ExceptionString></Exception></TraceRecord>
The program '[7424] ProgramName.vshost.exe' has exited with code -1073741819 (0xc0000005) 'Access violation'.
The weird part is the code window goes to where the problem is, but the debug stops at the same time without a popup.
So did I accidentally check off some option I really needed or do something stupid that is easy to fix. Is this an issue with my code or maybe a permission setting?
Edit:
Debug mode is on:

Unhandled Access Violations in VB.NET [duplicate]

This question already has answers here:
How to handle AccessViolationException
(5 answers)
Closed 8 years ago.
I have a program that I cannot capture a random error and it crashes the process. I read the article on .NET 4 Framework not capturing System.AccessViolationException errors anymore unless you turn on a switch http://msdn.microsoft.com/en-us/library/dd638517(v=vs.110).aspx but it does not seem to work all the time. Has anyone had experience with this happening and how to capture these errors?
Here is the required switch I put in the the app.config:
<configuration>
<runtime>
<legacyCorruptedStateExceptionsPolicy enabled="true" />
</runtime>
...
Here is the error report:
Log Name: Application
Source: .NET Runtime
Date: 8/19/2014 4:02:50 PM
Event ID: 1026
Task Category: None
Level: Error
Keywords: Classic
User: N/A
Computer: Test.local
Description:
Application: mainproc.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.AccessViolationException
Stack:
at ADODB.RecordsetClass.Open(System.Object, System.Object, ADODB.CursorTypeEnum, ADODB.LockTypeEnum, Int32)
at ADODB.RecordsetClass.Open(System.Object, System.Object, ADODB.CursorTypeEnum, ADODB.LockTypeEnum, Int32)
at CEMain.clsThreadWritebackBatch.
(ADODB.Connection ByRef)
at CEMain.clsThreadWritebackBatch.ProcessBatch()
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Threading.ThreadHelper.ThreadStart()
NEW:
The code below is where I think the problem may have occurred, I would value an opinion.
Try
OpenBackendDatabase(cn, False)
ProcessQueue(cn)
Catch
Trace("ProcessBatch: " & Err.Description, True)
Finally
CloseBackendDatabase(cn)
RaiseEvent FinishedBatch(123)
End Try
So my thought was, if anything bad happens the FINALLY would close the database connection. The CloseBackendDatabase function has its own error handling. But now I am thinking if the "cn" reference was gone (pointer), then calling the ClockBackendDatabase function with a bad "cn" reference could cause an unhandled error? Does that make sense? If so, would this be a possible fix:
Try
OpenBackendDatabase(cn, False)
ProcessQueue(cn)
Catch
Trace("ProcessBatch: " & Err.Description, True)
Finally
Try
CloseBackendDatabase(cn)
Catch
End Try
RaiseEvent FinishedBatch(123)
End Try
The easy fix is to check if the object exists before calling your close function:
If cn IsNot Nothing Then CloseBackendDatabase(cn)

Biztalk 2013 <string xmlns='http://schemas.microsoft.com/2003/10/Serialization/'> was not expected

I have a BizTalk 2013 orchestration which I published as a WCF service. The orchestration has a Request-Response port accepting a string and returning an entity which I have defined in a schema.
When I try use the service and pass a string to it, I get the error
http://schemas.microsoft.com/2003/10/Serialization/'> was not expected.
Does anyone have any ideas how to fix this?
Thanks
Full error details below:
xlang/s engine event log entry: Uncaught exception (see the 'inner
exception' below) has suspended an instance of service
'CAA.POC.ESB.BizTalk.Orchestrations.RetrieveAllCases(c408d4a7-3795-f6c7-dc95-c02edfe00740)'.
The service instance will remain suspended until administratively
resumed or terminated. If resumed the instance will continue from its
last persisted state and may re-throw the same unexpected exception.
InstanceId: 6b9cbf6a-2a63-4401-b3a1-05a870da963c Shape name:
ConstructCases ShapeId: 189c5a7f-2306-49dc-bd07-8430e638ba45 Exception
thrown from: segment 1, progress 7 Inner exception: There is an error
in XML document (1, 2).
Exception type: InvalidOperationException Source: System.Xml Target Site: System.Object Deserialize(System.Xml.XmlReader,
System.String, System.Xml.Serialization.XmlDeserializationEvents) The
following is a stack trace that identifies the location where the
exception occured
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader
xmlReader, String encodingStyle, XmlDeserializationEvents events)
at System.Xml.Serialization.XmlSerializer.Deserialize(TextReader
textReader) at Microsoft.XLANGs.Core.Value.GetObject(Type t) at
Microsoft.XLANGs.Core.Value.RetrieveAs(Type t) at
Microsoft.XLANGs.Core.Part.ProtectedRetrieveAs(Type t) at
Microsoft.XLANGs.Core.Part.RetrieveAs(Type t) at
CAA.POC.ESB.BizTalk.Orchestrations.System_String.get_TypedValue()
at
CAA.POC.ESB.BizTalk.Orchestrations.RetrieveAllCases.segment1(StopConditions
stopOn) at
Microsoft.XLANGs.Core.SegmentScheduler.RunASegment(Segment s,
StopConditions stopCond, Exception& exp) Additional error information:
<string xmlns='http://schemas.microsoft.com/2003/10/Serialization/'> was not
expected.
Exception type: InvalidOperationException Source: System.Xml Target Site: System.Object Read_string() The following is a stack
trace that identifies the location where the exception occured
at
System.Xml.Serialization.XmlSerializationPrimitiveReader.Read_string()
at
System.Xml.Serialization.XmlSerializer.DeserializePrimitive(XmlReader
xmlReader, XmlDeserializationEvents events) at
System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader
xmlReader, String encodingStyle, XmlDeserializationEvents events)