Bug 7240 - C# compiler incorrectly reports type mismatch when referencing a library that references a local assembly that's also in the GAC and your app also references the local assembly
Summary: C# compiler incorrectly reports type mismatch when referencing a library that...
Status: NEW
Alias: None
Product: Tools
Classification: Mono
Component: xbuild ()
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-09-17 20:49 UTC by Greg Najda
Modified: 2012-09-18 03:18 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Projects demonstrating the problem (699.44 KB, application/zip)
2012-09-17 20:49 UTC, Greg Najda
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 7240 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
NEW

Description Greg Najda 2012-09-17 20:49:56 UTC
Created attachment 2561 [details]
Projects demonstrating the problem

For example, if you have a project called Library that references a local Npgsql dll in a lib folder and an application called GACReferenceTest that references the Library project and the local Npgsql dll and you happen to have Npgsql installed in the GAC (perhaps a difference version than the local Npgsql), you will get an error when trying to compile GACReferenceTest.

A pair of projects demonstrating the problem is attached. You must have Npgsql installed in the GAC for the problem to manifest.


xbuild output:


greg@Kubuntu:~/dev/GACReferenceTest/GACReferenceTest$ xbuild GACReferenceTest.csproj 
XBuild Engine Version 2.10.8.1
Mono, Version 2.10.8.1
Copyright (C) Marek Sieradzki 2005-2008, Novell 2008-2011.

Build started 9/17/2012 8:34:06 PM.
__________________________________________________
Project "/home/greg/dev/GACReferenceTest/GACReferenceTest/GACReferenceTest.csproj" (default target(s)):
        Target PrepareForBuild:
                Configuration: Debug Platform: x86
                Created directory "bin/Debug/"
                Created directory "obj/x86/Debug/"
        Target ResolveProjectReferences:
                Project "/home/greg/dev/GACReferenceTest/Library/Library.csproj" (default target(s)):
                        Target PrepareForBuild:
                                Configuration: Debug Platform: AnyCPU
                                Created directory "bin/Debug/"
                                Created directory "obj/Debug/"
                        Target ResolveAssemblyReferences:
/usr/lib/mono/4.0/Microsoft.Common.targets:  warning : Found a conflict between : 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' and 'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. Using 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' reference.
                        Target CopyFilesMarkedCopyLocal:
                                Copying file from '/home/greg/dev/GACReferenceTest/lib/Npgsql/mono20/Npgsql.dll' to '/home/greg/dev/GACReferenceTest/Library/bin/Debug/Npgsql.dll'
                        Target GenerateSatelliteAssemblies:
                        No input files were specified for target GenerateSatelliteAssemblies, skipping.
                        Target CoreCompile:
                                Tool /usr/bin/dmcs execution started with arguments: /noconfig /debug:full /debug+ /optimize- /out:obj/Debug/Library.dll MyClass.cs AssemblyInfo.cs /target:library /define:DEBUG /reference:/usr/lib/mono/4.0/System.dll /reference:../lib/Npgsql/mono20/Npgsql.dll /reference:/usr/lib/mono/4.0/System.Core.dll /reference:/usr/lib/mono/4.0/mscorlib.dll /reference:/usr/lib/mono/4.0/System.Data.dll /reference:/usr/lib/mono/4.0/Mono.Security.dll /reference:/usr/lib/mono/4.0/System.Transactions.dll /warn:4
                        Target DeployOutputFiles:
                                Copying file from '/home/greg/dev/GACReferenceTest/Library/obj/Debug/Library.dll.mdb' to '/home/greg/dev/GACReferenceTest/Library/bin/Debug/Library.dll.mdb'
                                Copying file from '/home/greg/dev/GACReferenceTest/Library/obj/Debug/Library.dll' to '/home/greg/dev/GACReferenceTest/Library/bin/Debug/Library.dll'
                Done building project "/home/greg/dev/GACReferenceTest/Library/Library.csproj".
        Target ResolveAssemblyReferences:
/usr/lib/mono/4.0/Microsoft.Common.targets:  warning : Found a conflict between : 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' and 'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. Using 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' reference.
        Target CopyFilesMarkedCopyLocal:
                Copying file from '/home/greg/dev/GACReferenceTest/lib/Npgsql/mono20/Npgsql.dll' to '/home/greg/dev/GACReferenceTest/GACReferenceTest/bin/Debug/Npgsql.dll'
                Copying file from '/home/greg/dev/GACReferenceTest/Library/bin/Debug/Library.dll' to '/home/greg/dev/GACReferenceTest/GACReferenceTest/bin/Debug/Library.dll'
                Copying file from '/home/greg/dev/GACReferenceTest/Library/bin/Debug/Library.dll.mdb' to '/home/greg/dev/GACReferenceTest/GACReferenceTest/bin/Debug/Library.dll.mdb'
        Target GenerateSatelliteAssemblies:
        No input files were specified for target GenerateSatelliteAssemblies, skipping.
        Target CoreCompile:
                Tool /usr/bin/dmcs execution started with arguments: /noconfig /debug:full /debug+ /optimize- /out:obj/x86/Debug/GACReferenceTest.exe Main.cs AssemblyInfo.cs /target:exe /define:DEBUG /platform:x86 /reference:/usr/lib/mono/4.0/System.dll /reference:../lib/Npgsql/mono20/Npgsql.dll /reference:/usr/lib/mono/4.0/System.Core.dll /reference:/home/greg/dev/GACReferenceTest/Library/bin/Debug//Library.dll /reference:/usr/lib/mono/4.0/mscorlib.dll /reference:/usr/lib/mono/4.0/System.Data.dll /reference:/usr/lib/mono/4.0/Mono.Security.dll /reference:/usr/lib/mono/4.0/System.Transactions.dll /warn:4
Main.cs(11,30): error CS0029: Cannot implicitly convert type `Npgsql.NpgsqlConnection' to `Npgsql.NpgsqlConnection'
        Task "Csc" execution -- FAILED
        Done building target "CoreCompile" in project "/home/greg/dev/GACReferenceTest/GACReferenceTest/GACReferenceTest.csproj".-- FAILED
Done building project "/home/greg/dev/GACReferenceTest/GACReferenceTest/GACReferenceTest.csproj".-- FAILED

Build FAILED.

Warnings:

/home/greg/dev/GACReferenceTest/GACReferenceTest/GACReferenceTest.csproj (default targets) ->
/usr/lib/mono/4.0/Microsoft.Common.targets (ResolveProjectReferences target) ->
/home/greg/dev/GACReferenceTest/Library/Library.csproj (default targets) ->
/usr/lib/mono/4.0/Microsoft.Common.targets (ResolveAssemblyReferences target) ->

        /usr/lib/mono/4.0/Microsoft.Common.targets:  warning : Found a conflict between : 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' and 'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. Using 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' reference.

/home/greg/dev/GACReferenceTest/GACReferenceTest/GACReferenceTest.csproj (default targets) ->
/usr/lib/mono/4.0/Microsoft.Common.targets (ResolveAssemblyReferences target) ->

        /usr/lib/mono/4.0/Microsoft.Common.targets:  warning : Found a conflict between : 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' and 'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. Using 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' reference.

Errors:

/home/greg/dev/GACReferenceTest/GACReferenceTest/GACReferenceTest.csproj (default targets) ->
/usr/lib/mono/4.0/Microsoft.CSharp.targets (CoreCompile target) ->

        Main.cs(11,30): error CS0029: Cannot implicitly convert type `Npgsql.NpgsqlConnection' to `Npgsql.NpgsqlConnection'

         2 Warning(s)
         1 Error(s)

Time Elapsed 00:00:01.3354160