This project is read-only.


Invoking an extension method in an external library (NServiceBus) is causing compiler error CS1061


Steps to reproduce:
Clone this repository and compile with Roslyn or
1) Create new project
2) Install NServiceBus v2.6.0.1511 with NuGet
3) Try to call NServiceBus.Configure.WithWeb().Log4Net()

Expected results:
I expect this to compile, it is working fine with the old compiler.

Actual results:
Invoking the method as a static method works but not as an extension method, it results in the following compiler error.
error CS1061: 'NServiceBus.Configure' does not contain a definition for 'Log4Net' and no extension method 'Log4Net' accepting a first argument of type 'NServiceBus.Configure' could be found (are you missing a using directive or an assembly reference?)


Kevin_H wrote Apr 17, 2014 at 8:35 AM

Hi David,

This is actually a known breaking change with Roslyn that should be fixed if you're referencing NServiceBus (beta) 4.0.0-beta0001 or newer.

The issue is that the Roslyn C# compiler checks assemblies for an assembly-level System.Runtime.CompilerServices.ExtensionAttribute before attempting to materialize symbols for that assembly during extension method lookup. The benefit of this approach is reduced memory pressure for language analysis scenarios (like the VS editor), but unfortunately it breaks compat with some assemblies produced by older IL rewriting tools that may drop this attribute on the floor...

The recommendation here would be to upgrade to a newer version of NServiceBus in order to utilize Roslyn.