question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[FYI] LoadAssembliesOnStart + Anotar

See original GitHub issue

The 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:closed
  • Created 4 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
GeertvanHorrikcommented, Feb 26, 2020

LAOS Build - 4.4.0-beta.1+2 has been released.

0reactions
GeertvanHorrikcommented, Feb 26, 2020

@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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Resolve dependency when an assembly is loaded using ...
FYI : I am trying to load assembly which uses FileHelpers.dll and it calls on ClassBuilder.ClassFromString function. Assembly load fails with ...
Read more >
How to: Load Assemblies into an Application Domain
Learn how to load assemblies into an application domain in .NET. The recommended way is to use the static (or Shared) Load method...
Read more >
[Feature] assembly loading in .NET Standard and .NET Core
This topic will address how to manage assembly loading scenarios in .NET Standard and .NET Core libraries and applications.
Read more >
"unloading broken assembly", "could not load signature"
I believe the build works correctly because all of the assemblies get moved to the same folder (Data/Managed), so there are no issues...
Read more >
WPF controls can not load design-time assemblies in ...
Hi,. We observed a situation that when we load our controls in VS2019 RC by drag this dll to toolbox directly, all controls...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found