Could not load file or assembly ‘System.ComponentModel.Annotations, Version=4.1.0.0

In many cases, this can be solved by adding the following code to the csproj file of your test project: <PropertyGroup> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType> </PropertyGroup> This forces the build process to create a .dll.config file in the output directory with the needed binding redirects. The reason is that “classic” csproj test projects are true “libraries” and … Read more

Monotouch/WCF: How to consume the wcf service without svcutil

ChannelFactory<T> has a virtual method CreateChannel(). If this is not overridden, it uses dynamic code generation, which fails on MonoTouch. The solution is to override it and provide your own compile-time implementation. Below is an old service implementation of mine that at least used to work on MonoTouch. I split it up into 2 partial … Read more

Auto Versioning in Visual Studio 2017 (.NET Core)

Add <Deterministic>False</Deterministic> inside a <PropertyGroup> section  of .csproj The workaround to make AssemblyVersion * working is described in “Confusing error message for wildcard in [AssemblyVersion] on .Net Core #22660” Wildcards are only allowed if the build is not deterministic, which is the default for .Net Core projects. Adding <Deterministic>False</Deterministic> to csproj fixes the issue. The reasons why .Net Core … Read more

Should I take ILogger, ILogger, ILoggerFactory or ILoggerProvider for a library?

Definition We have 3 interfaces: ILogger, ILoggerProvider and ILoggerFactory. Let’s look at the source code to find out their responsibilities: ILogger: is responsible to write a log message of a given Log Level. ILoggerProvider: is responsible to create an instance of ILogger (you are not supposed to use ILoggerProvider directly to create a logger) ILoggerFactory: … Read more

Compatibility shim used by .NET Standard 2.0

This works by creating all the necessary libraries that are referenced by classic .NET libraries. E.g. in .NET Core the implementation of Object or Attribute is defined in System.Runtime. When you compile code, the generated code always references the assembly and the type => [System.Runtime]System.Object. Classic .NET projects however reference System.Object from mscorlib. When trying … Read more