[FYI] LoadAssembliesOnStart + Anotar
See original GitHub issueThe issue and a possible fix
This is just a FYI, if you use Anotar in conjunction with LoadAssembliesOnStart, you might run into this exception:
System.TypeInitializationException
HResult=0x80131534
Message=The type initializer for '<Module>' threw an exception.
Source=<Cannot evaluate the exception source>
StackTrace:
<Cannot evaluate the exception stack trace>
Inner Exception 1:
TypeInitializationException: The type initializer for '<Module>' threw an exception.
Inner Exception 2:
FileNotFoundException: Could not load file or assembly 'Anotar.Serilog, Version=5.1.0.0, Culture=neutral, PublicKeyToken=9d5b24f0733c26f7' or one of its dependencies. The system cannot find the file specified.
This is because LoadAssembliesOnStart prevents the Anotar.XXX dependency from being removed properly.
The proposed (userland) fix is simple: <LoadAssembliesOnStartup ExcludeAssemblies='Anotar.Serilog' />
Replace Serilog with the version of Anotar you are using.
Discussion
-
I am uncertain how LoadAssembliesOnStart proceeds, but I suspect this issue might also be avoided if one changes the order in which Weavers are executed ?
-
I also suspect this only happens when you are actually referencing some of the weaver’s library code in your own code (e.g. that doesn’t happen with PropertyChanged (I don’t use any of the attributes))
Hoping this will be reach whoever needs it. Thanks for this great library !
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (4 by maintainers)
LAOS Build - 4.4.0-beta.1+2 has been released.
@alexis- is correct, you can exclude this assembly by specifying it. The order can also “fix things” because once the anotar weaver has done its job, the reference will no longer be there.
What we did for some common things in LoadAssemblieOnStartup is add known assemblies to ignore (see https://github.com/Fody/LoadAssembliesOnStartup/blob/develop/src/LoadAssembliesOnStartup.Fody/Weaving/ReferenceSelector.cs#L32).
I’ve added this assembly to the list of known exact assemblies, will no longer be an issue in a future release of LAOS