Quantcast
Channel: Common Language Runtime Internals and Architecture forum
Viewing all articles
Browse latest Browse all 1710

AppDomain.CurrentDomain.Evidence throws SerializationException

$
0
0

I got a strange error when running my test cases using ReSharper (8.2.2) with VS 2013.

My application does the following:

1) Set a custom object (it is serializable) in a slot on CallContext.

CallContext.LogicalSetData(key, new ActivityStack());

2) Then retrieve Evidence from current AppDomain:

var evidence = AppDomain.CurrentDomain.Evidence;

The second step would throw an exception:

System.Runtime.Serialization.SerializationException was unhandled by user code
  HResult=-2146233076
  Message=Type is not resolved for member 'CSG.Framework.Operations.ActivityStack,CSG.Framework, Version=15.2.0.0, Culture=neutral, PublicKeyToken=e7ab1d859f54b223'.
  Source=mscorlib
  StackTrace:
       at System.AppDomain.get_Evidence()
       at System.AppDomain.get_Evidence()
       at CSG.Framework.Utilities.AppDomainLauncher`1..ctor(String appDomainName) in d:\Work\Git\Framework\Src\Library\Framework\Utilities\AppDomainLauncher.cs:line 40
       at CSG.Framework.UnitTest.AppDomainLauncherTests.LaunchClassFromCallingAssembly() in d:\Work\Git\Framework\Src\Library\Framework.UnitTest\Utilities\AppDomainLauncherTests.cs:line 52
  InnerException: 

Even though the current AppDomain appears to have the correct path on BaseDirectory where the assembly containing the type can be found, CLR appears to be still using the ReSharper bin path to probe for the assembly according to Fusion log. The problem would go away if I copy the assembly to ReSharper bin folder. I tried to subscribe to AssemblyResolve event on current AppDomain, but the handler did not get called. 

Dump of AppDomain.CurrentDomain value before calling AppDomain.Evidence:

Fusion log:

=== Pre-bind state information === LOG: DisplayName = CSG.Framework, Version=15.2.0.0, Culture=neutral, PublicKeyToken=e7ab1d859f54b223 (Fully-specified) LOG: Appbase = file:///C:/Program Files (x86)/JetBrains/ReSharper/v8.2.Qiwabic/Bin/ LOG: Initial PrivatePath = NULL LOG: Dynamic Base = NULL LOG: Cache Base = NULL LOG: AppName = JetBrains.ReSharper.TaskRunner.CLR45.x64.exe Calling assembly : (Unknown). === LOG: This bind starts in default load context. LOG: Using application configuration file: C:\Program Files (x86)\JetBrains\ReSharper\v8.2.Qiwabic\Bin\JetBrains.ReSharper.TaskRunner.CLR45.x64.exe.Config LOG: Using host configuration file: LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config. LOG: Post-policy reference: CSG.Framework, Version=15.2.0.0, Culture=neutral, PublicKeyToken=e7ab1d859f54b223 LOG: GAC Lookup was unsuccessful. LOG: Attempting download of new URL file:///C:/Program Files (x86)/JetBrains/ReSharper/v8.2.Qiwabic/Bin/CSG.Framework.DLL. LOG: Attempting download of new URL file:///C:/Program Files (x86)/JetBrains/ReSharper/v8.2.Qiwabic/Bin/CSG.Framework/CSG.Framework.DLL. LOG: Attempting download of new URL file:///C:/Program Files (x86)/JetBrains/ReSharper/v8.2.Qiwabic/Bin/CSG.Framework.EXE. LOG: Attempting download of new URL file:///C:/Program Files (x86)/JetBrains/ReSharper/v8.2.Qiwabic/Bin/CSG.Framework/CSG.Framework.EXE. LOG: All probing URLs attempted and failed.


Viewing all articles
Browse latest Browse all 1710

Trending Articles