jbailey.spatialbridge

CannotUnloadAppDomainException when starting a LocalGeometryService in an add-in

Discussion created by jbailey.spatialbridge on May 24, 2012
Latest reply on May 24, 2012 by jbailey.spatialbridge
I've created a small prototype to test accessing ArcGIS Runtime functionality from within a WPF application plug-in. I've created a simple add-in that, when invoked, creates a LocalGeometryService and calls StartAsync. After the application loads, after a few seconds an unhandled CannotUnloadAppDomainException occurs:

System.CannotUnloadAppDomainException was unhandled
  Message=Error while unloading appdomain. (Exception from HRESULT: 0x80131015)
  Source=mscorlib
  StackTrace:
       at System.AppDomain.Unload(AppDomain domain)
       at System.AddIn.Pipeline.ContractBase.AppDomainUnload()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException:


If the add-in doesn't call StartAsync on the LocalGeometryService, then the exception does not occur.

Ideas on why this is happening?

Thanks,

Jon.

Following is some of the output from the application (truncated to fit within the post):

'ArcGISWPFPlugInHost.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities.Sync\10.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.Sync.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ArcGISWPFPlugInHost.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.Debugger.Runtime\10.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Debugger.Runtime.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ArcGISWPFPlugInHost.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\temp\ArcGISWPFPlugIns\ArcGISWPFPlugInHost.vshost.exe', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ArcGISWPFPlugInHost.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.AddIn\v4.0_4.0.0.0__b77a5c561934e089\System.AddIn.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ArcGISWPFPlugInHost.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ArcGISWPFPlugInHost.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ArcGISWPFPlugInHost.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ArcGISWPFPlugInHost.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.CSharp\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.CSharp.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ArcGISWPFPlugInHost.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml.Linq\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.Linq.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ArcGISWPFPlugInHost.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Data.DataSetExtensions\v4.0_4.0.0.0__b77a5c561934e089\System.Data.DataSetExtensions.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ArcGISWPFPlugInHost.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xaml\v4.0_4.0.0.0__b77a5c561934e089\System.Xaml.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ArcGISWPFPlugInHost.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\WindowsBase\v4.0_4.0.0.0__31bf3856ad364e35\WindowsBase.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ArcGISWPFPlugInHost.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_32\PresentationCore\v4.0_4.0.0.0__31bf3856ad364e35\PresentationCore.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ArcGISWPFPlugInHost.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework\v4.0_4.0.0.0__31bf3856ad364e35\PresentationFramework.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
The thread 'vshost.NotifyLoad' (0x11b4) has exited with code 0 (0x0).
The thread 'vshost.LoadReference' (0xb88) has exited with code 0 (0x0).
'ArcGISWPFPlugInHost.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\temp\ArcGISWPFPlugIns\ArcGISWPFPlugInHost.exe', Symbols loaded.
'ArcGISWPFPlugInHost.vshost.exe' (Managed (v4.0.30319)): 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.
Step into: Stepping over non-user code 'ArcGISWPFPlugInHost.App.App'
Step into: Stepping over non-user code 'ArcGISWPFPlugInHost.App.InitializeComponent'
'ArcGISWPFPlugInHost.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\temp\ArcGISWPFPlugIns\ArcGISWPFHostView.dll', Symbols loaded.
'ArcGISWPFPlugInHost.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\temp\ArcGISWPFPlugIns\ESRI.ArcGIS.Client.dll'
'ArcGISWPFPlugInHost.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\temp\ArcGISWPFPlugIns\ESRI.ArcGIS.Client.Local.dll'
'ArcGISWPFPlugInHost.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework.Aero\v4.0_4.0.0.0__31bf3856ad364e35\PresentationFramework.Aero.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ArcGISWPFPlugInHost.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.AddIn.Contract\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.AddIn.Contract.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ArcGISWPFPlugInHost.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\temp\ArcGISWPFPlugIns\Pipeline\Contracts\ArcGISWPFPlugInContract.dll', Symbols loaded.
'ArcGISWPFPlugInHost.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\temp\ArcGISWPFPlugIns\Pipeline\AddInViews\ArcGISWPFPlugInView.dll', Symbols loaded.
'ArcGISWPFPlugInHost.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\temp\ArcGISWPFPlugIns\Pipeline\AddIns\ArcGISWPFPlugIn\ArcGISWPFPlugIn.dll', Symbols loaded.
'ArcGISWPFPlugInHost.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\temp\ArcGISWPFPlugIns\Pipeline\AddInSideAdapters\ArcGISWPFPlugInAdapter.dll', Symbols loaded.
'ArcGISWPFPlugInHost.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\temp\ArcGISWPFPlugIns\Pipeline\AddIns\ArcGISWPFPlugIn\ESRI.ArcGIS.Client.Local.dll'
ArcGISWPFPlugIn created
'ArcGISWPFPlugInHost.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\temp\ArcGISWPFPlugIns\Pipeline\AddIns\ArcGISWPFPlugIn\ESRI.ArcGIS.Client.dll'
ArcGISRuntime: ArcGIS Runtime starting 
'ArcGISWPFPlugInHost.vshost.exe' (Managed (v4.0.30319)): Loaded 'Anonymously Hosted DynamicMethods Assembly'
ArcGISRuntime: ArcGIS Runtime started version: 1.0.0.3057 url: http://127.0.0.1:50000/nPkjFB/arcgis/rest/services
'ArcGISWPFPlugInHost.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\temp\ArcGISWPFPlugIns\Pipeline\HostSideAdapters\ArcGISWPFHostAdapter.dll', Symbols loaded.
'ArcGISWPFPlugInHost.vshost.exe' (Managed (v4.0.30319)): Loaded 'Anonymously Hosted DynamicMethods Assembly'
ArcGISRuntime: ArcGIS Runtime starting 
'ArcGISWPFPlugInHost.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\UIAutomationTypes\v4.0_4.0.0.0__31bf3856ad364e35\UIAutomationTypes.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
ArcGISRuntime: ArcGIS Runtime started version: 1.0.0.3057 url: http://127.0.0.1:50001/yt3GjG/arcgis/rest/services
'ArcGISWPFPlugInHost.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.Serialization\v4.0_4.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll'
'ArcGISWPFPlugInHost.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\SMDiagnostics\v4.0_4.0.0.0__b77a5c561934e089\SMDiagnostics.dll'
'ArcGISWPFPlugInHost.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.DurableInstancing\v4.0_4.0.0.0__31bf3856ad364e35\System.Runtime.DurableInstancing.dll'
The thread '<No Name>' (0xd80) has exited with code 0 (0x0).
The thread '<Thread Ended>' (0x117c) has exited with code 0 (0x0).

Attachments

Outcomes