Yann
Yann

Reputation: 445

Prism + Log4Net build error : "Cannot resolve dependency to assembly log4net"

I am trying to add log4net support in a Prism application. Unfortunately i get the following error for each prism modules :

Error 101 Unknown build error, 'Cannot resolve dependency to assembly 'log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821' because it has not been preloaded. When using the ReflectionOnly APIs, dependent assemblies must be pre-loaded or loaded on demand through the ReflectionOnlyAssemblyResolve event.' [PRISM MODULE 1 PROJECT NAME]

Error 101 Unknown build error, 'Cannot resolve dependency to assembly 'log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821' because it has not been preloaded. When using the ReflectionOnly APIs, dependent assemblies must be pre-loaded or loaded on demand through the ReflectionOnlyAssemblyResolve event.' [PRISM MODULE 2 PROJECT NAME]

ect ...

I set up the logger as follow :

  1. I added log4net assembly reference to both the main app, and the bootstrapper.
  2. I added log4net configuration to the app.config file.
  3. I added [assembly: log4net.Config.XmlConfigurator(Watch = true)] to the App.xaml.cs file.
  4. I created a logger implemeting ILoggerFacade and overwrote CreateLogger() in the Bootstrapper to make it return my custom logger.

That's it. If i try to build, it fails with the error mentioned above for each prism module project. The only work around i found was to manually add log4net references to each prism modules projects which, i think, kind of defeats the abstraction between ILoggerFacade and the dependencies of the actual implementation.

The error suggest to use the ReflectionOnlyAssemblyResolve event, but i don't see how it could help here as it is a build error, not runtime.

Any suggestion ? :-)

Upvotes: 1

Views: 1809

Answers (1)

Yann
Yann

Reputation: 445

Ok i found the problem, each modules were referencing the bootstrapper which is just wrong, i removed that dependency and VOILA, fixed !

Upvotes: 0

Related Questions