Bug 17251 - AppDomain.Load fails to use AssemblyResolve when using Shadow Copy
Summary: AppDomain.Load fails to use AssemblyResolve when using Shadow Copy
Status: RESOLVED FIXED
Alias: None
Product: Runtime
Classification: Mono
Component: Reflection ()
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-01-15 11:58 UTC by Jan Lamecki
Modified: 2014-01-17 16:07 UTC (History)
4 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
example program showing mono failure (754 bytes, text/x-csharp)
2014-01-15 11:58 UTC, Jan Lamecki
Details
Proposed patch (MIT X11 license) (1.04 KB, patch)
2014-01-16 10:38 UTC, Jan Lamecki
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Jan Lamecki 2014-01-15 11:58:05 UTC
Created attachment 5844 [details]
example program showing mono failure

When using shadow copy mono does not try to find missing assemblies by AssemblyResolve.

Inner cause is shadow copy failing to copy not existing file (as expected) - bailing out of loading assembly in mono/metadata/assembly.c.

Exception is raised by mono/metadata/appdomain.c:mono_make_shadow_copy.

Attached example expected result (and actual result while running on .net):
Assembly not found (as expected)

Actual result:
Unhandled Exception:
System.ExecutionEngineException: Failed to create shadow copy (CopyFile).

Server stack trace: 
  at (wrapper managed-to-native) System.AppDomain:LoadAssembly (System.AppDomain,string,System.Security.Policy.Evidence,bool)
  at System.AppDomain.Load (System.Reflection.AssemblyName assemblyRef, System.Security.Policy.Evidence assemblySecurity) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.AppDomain:Load (System.Reflection.AssemblyName,System.Security.Policy.Evidence)
  at System.AppDomain.Load (System.Reflection.AssemblyName assemblyRef) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.AppDomain:Load (System.Reflection.AssemblyName)
  at System.Reflection.Assembly.Load (System.Reflection.AssemblyName assemblyRef) [0x00000] in <filename unknown>:0 
  at shadowcopytest.MainClass.executeInShadowDomain () [0x00000] in <filename unknown>:0 
  at System.AppDomain.DoCallBack (System.CrossAppDomainDelegate callBackDelegate) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.AppDomain:DoCallBack (System.CrossAppDomainDelegate)
  at (wrapper xdomain-dispatch) System.AppDomain:DoCallBack (object,byte[]&,byte[]&)

Exception rethrown at [0]: 

  at (wrapper xdomain-invoke) System.AppDomain:DoCallBack (System.CrossAppDomainDelegate)
  at (wrapper remoting-invoke-with-check) System.AppDomain:DoCallBack (System.CrossAppDomainDelegate)
  at shadowcopytest.MainClass.Main (System.String[] args) [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.ExecutionEngineException: Failed to create shadow copy (CopyFile).

Server stack trace: 
  at (wrapper managed-to-native) System.AppDomain:LoadAssembly (System.AppDomain,string,System.Security.Policy.Evidence,bool)
  at System.AppDomain.Load (System.Reflection.AssemblyName assemblyRef, System.Security.Policy.Evidence assemblySecurity) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.AppDomain:Load (System.Reflection.AssemblyName,System.Security.Policy.Evidence)
  at System.AppDomain.Load (System.Reflection.AssemblyName assemblyRef) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.AppDomain:Load (System.Reflection.AssemblyName)
  at System.Reflection.Assembly.Load (System.Reflection.AssemblyName assemblyRef) [0x00000] in <filename unknown>:0 
  at shadowcopytest.MainClass.executeInShadowDomain () [0x00000] in <filename unknown>:0 
  at System.AppDomain.DoCallBack (System.CrossAppDomainDelegate callBackDelegate) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.AppDomain:DoCallBack (System.CrossAppDomainDelegate)
  at (wrapper xdomain-dispatch) System.AppDomain:DoCallBack (object,byte[]&,byte[]&)

Exception rethrown at [0]: 

  at (wrapper xdomain-invoke) System.AppDomain:DoCallBack (System.CrossAppDomainDelegate)
  at (wrapper remoting-invoke-with-check) System.AppDomain:DoCallBack (System.CrossAppDomainDelegate)
  at shadowcopytest.MainClass.Main (System.String[] args) [0x00000] in <filename unknown>:0
Comment 1 Jan Lamecki 2014-01-16 10:38:00 UTC
Created attachment 5856 [details]
Proposed patch (MIT X11 license)

Attached proposed patch against git tag mono-3.2.3, tested on GNU/Linux. Passes "make check" in "mono" directory. MIT X11 licensed.
Comment 2 Rodrigo Kumpera 2014-01-17 16:07:33 UTC
Fixed and thanks for the patch.