aspnetcore icon indicating copy to clipboard operation
aspnetcore copied to clipboard

Interface resolution issue when using wrapped project with ASP.NET 5 target framework

Open bojanrajkovic opened this issue 11 years ago • 4 comments

I have an old-style project that's being referenced through a wrapper by an ASP.NET 5 project. When the ASP.NET 5 project is using the aspnet50 framework, this causes the following compiler error when using CTP 5 or KRE beta 2:

Program.cs(13,30): error CS7069: Reference to type 'ILoggerFactory' claims it is defined in 'Microsoft.Framework.Logging.Interfaces', but it could not be found

When using KRE beta 3 (10921), a different error is produced:

Program.cs(9,25): error CS0246: The type or namespace name 'ILoggerFactory' could not be found (are you missing a using directive or an assembly reference?)

Program.cs(12,13): error CS0012: The type 'ILoggerFactory' is defined in an assembly that is not referenced. You must add a reference to assembly 'Microsoft.Framework.Logging.ILoggerFactory, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.

Program.cs(13,30): error CS7069: Reference to type 'ILoggerFactory' claims it is defined in 'Microsoft.Framework.Logging.Interfaces', but it could not be found

Switching the target framework of the ASP.NET 5 project to net45 resolved the compiler error, but prevents references to ASP.NET MVC 6, etc.. Switching all of the NuGet package versions to -beta3-10752 and using the beta3 KRE also doesn't work, with the same error as the all beta2 setup:

Program.cs(13,30): error CS7069: Reference to type 'ILoggerFactory' claims it is defined in 'Microsoft.Framework.Logging.Interfaces', but it could not be found

The reproduction solution is in https://dl.dropboxusercontent.com/u/66703527/BrokenLoggerReproTest.zip and should fail to build with one of the above errors depending on the versions in use.

bojanrajkovic avatar Jan 22 '15 02:01 bojanrajkovic

There was a breaking change made to the compiler with respect to assembly neutral interfaces. Stick the similar versions of the packages and KRE.

davidfowl avatar Jan 22 '15 03:01 davidfowl

I did that, still broken. See the 3rd block -- I set all the versions to beta3 and still got that CS7069. I can re-create it again with more screenshots and update the repro to beta3 if you want.

bojanrajkovic avatar Jan 22 '15 03:01 bojanrajkovic

Do this. Close VS, delete all user files set the default version to beta2 using kvm. Open VS

davidfowl avatar Jan 22 '15 04:01 davidfowl

Closing as per discussion on JabbR, this is just the way ANIs work. You can't mix usage of an ANI in a non-ASP.NET 5 and an ASP.NET 5 project.

bojanrajkovic avatar Jan 22 '15 04:01 bojanrajkovic