Bug 376876

Summary: Compiling with a ref to a lib that needs another lib, yields compiler exception
Product: [Mono] Mono: Compilers Reporter: Andres Aragoneses <aaragoneses>
Component: C#Assignee: Mono Bugs <mono-bugs>
Status: RESOLVED DUPLICATE QA Contact: Mono Bugs <mono-bugs>
Severity: Normal    
Priority: P5 - None CC: scott.ellington
Version: 1.9   
Target Milestone: ---   
Hardware: Other   
OS: openSUSE 10.3   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Andres Aragoneses 2008-04-03 17:20:13 UTC
The testcase is to pick a project that depends on ATK# and not place glib# in the same dir as this library. Results:

Performing main compilation...
Exception caught by the compiler while compiling:
   Block that caused the problem begin at: /home/knocte/Documents/iDocuments/Proyectos/mono/a11y/SVNtree/uia2atk/src/samples/managed/AtkSharpHelper/Main.cs(13,36):
                     Block being compiled: [/home/knocte/Documents/iDocuments/Proyectos/mono/a11y/SVNtree/uia2atk/src/samples/managed/AtkSharpHelper/Main.cs(14,17):,/home/knocte/Documents/iDocuments/Proyectos/mono/a11y/SVNtree/uia2atk/src/samples/managed/AtkSharpHelper/Main.cs(77,17):]
System.IO.FileNotFoundException: Could not load file or assembly 'gdk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f' or one of its dependencies.
Internal compiler error at /home/knocte/Documents/iDocuments/Proyectos/mono/a11y/SVNtree/uia2atk/src/samples/managed/AtkSharpHelper/Main.cs(13,36):: exception caught while emitting MethodBuilder [MainClass::Initialize]


** (/usr/lib/mono/2.0/gmcs.exe:14027): WARNING **: The following assembly referenced from /home/knocte/Documents/iDocuments/Proyectos/mono/a11y/SVNtree/gtk-sharp/gtk/gtk-sharp.dll could not be loaded:
     Assembly:   gdk-sharp    (assemblyref_index=2)
     Version:    2.12.0.0
     Public Key: 35e10195dab3c99f
The assembly was not found in the Global Assembly Cache, a path listed in the MONO_PATH environment variable, or in the location of the executing assembly (/home/knocte/Documents/iDocuments/Proyectos/mono/a11y/SVNtree/gtk-sharp/gtk).


** (/usr/lib/mono/2.0/gmcs.exe:14027): WARNING **: Could not load file or assembly 'gdk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f' or one of its dependencies.

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'gdk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f' or one of its dependencies.
File name: 'gdk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f'
  at (wrapper managed-to-native) System.Reflection.MonoMethodInfo:get_method_info (intptr,System.Reflection.MonoMethodInfo&)
  at System.Reflection.MonoMethod.get_Attributes () [0x00000] 
  at System.Reflection.MethodBase.get_IsVirtual () [0x00000] 
  at Mono.CSharp.MemberCache.AddMethods (BindingFlags bf, System.Type type) [0x00000] 
  at Mono.CSharp.MemberCache.AddMethods (System.Type type) [0x00000] 
  at Mono.CSharp.MemberCache..ctor (IMemberContainer container) [0x00000] 
  at Mono.CSharp.TypeHandle..ctor (System.Type type) [0x00000] 
  at Mono.CSharp.TypeHandle.GetTypeHandle (System.Type t) [0x00000] 
  at Mono.CSharp.TypeHandle.GetMemberCache (System.Type t) [0x00000] 
  at Mono.CSharp.TypeManager.MemberLookup_FindMembers (System.Type t, MemberTypes mt, BindingFlags bf, System.String name, System.Boolean& used_cache) [0x00000] 
  at Mono.CSharp.TypeManager.RealMemberLookup (System.Type invocation_type, System.Type qualifier_type, System.Type queried_type, MemberTypes mt, BindingFlags original_bf, System.String name, IList almost_match) [0x00000] 
  at Mono.CSharp.TypeManager.MemberLookup (System.Type invocation_type, System.Type qualifier_type, System.Type queried_type, MemberTypes mt, BindingFlags original_bf, System.String name, IList almost_match) [0x00000] 
  at Mono.CSharp.Expression.MemberLookup (System.Type container_type, System.Type qualifier_type, System.Type queried_type, System.String name, MemberTypes mt, BindingFlags bf, Location loc) [0x00000] 
  at Mono.CSharp.Expression.MemberLookup (System.Type container_type, System.Type qualifier_type, System.Type queried_type, System.String name, Location loc) [0x00000] 
  at Mono.CSharp.MemberAccess.DoResolve (Mono.CSharp.EmitContext ec, Mono.CSharp.Expression right_side) [0x00000] 
  at Mono.CSharp.MemberAccess.DoResolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags flags) [0x00000] 
  at Mono.CSharp.Invocation.DoResolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags flags) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.ExpressionStatement.ResolveStatement (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.StatementExpression.Resolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Block.Resolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.EmitContext.ResolveTopBlock (Mono.CSharp.EmitContext anonymous_method_host, Mono.CSharp.ToplevelBlock block, Mono.CSharp.Parameters ip, IMethodData md, System.Boolean& unreachable) [0x00000] 


Build complete -- 1 error, 0 warnings

---------------------- Done ----------------------

Build: 1 error, 0 warnings
Comment 1 Andres Aragoneses 2008-04-03 17:22:05 UTC
FYI: MonoDevelop has a bug related to this behaviour: bug 368625
Comment 2 Andres Aragoneses 2008-06-13 16:31:42 UTC
FYI: csc returns this type of errors:

Error	1	The type 'GLib.InitiallyUnowned' is defined in an assembly that is not referenced. You must add a reference to assembly 'glib-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f'.
Error	2	The type 'Atk.Implementor' is defined in an assembly that is not referenced. You must add a reference to assembly 'atk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f'.
Error	3	The type 'GLib.IWrapper' is defined in an assembly that is not referenced. You must add a reference to assembly 'glib-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f'.	

Comment 3 Andres Aragoneses 2008-06-13 16:48:38 UTC
Note that, to generate the errors of comment#2 in VisualStudio, I just had to write this line in a test project:

new Gtk.RadioButton ("");

So it seems that csc introspects the types in a way to see if there is a lack of references (in the project). However, gmcs doesn't introspect, and also it seems enough for it finding the DLL (glib-sharp.dll in the same folder as it's caller: gtk-sharper.dll) instead of requiring the compilation to reference it.
Comment 4 Andres Aragoneses 2009-02-08 01:46:31 UTC
The bug mentioned here is very related to this:
http://lists.ximian.com/pipermail/mono-patches/2009-February/141036.html
Comment 5 Andres Aragoneses 2009-02-13 05:10:18 UTC
*** Bug 443133 has been marked as a duplicate of this bug. ***
Comment 6 Marek Safar 2009-10-05 15:46:32 UTC
dup

*** This bug has been marked as a duplicate of bug 543537 ***