Bug 409646

Summary: Bad references while accessing to some .apxs files
Product: [Mono] Mono: Runtime Reporter: Maxim Karavaev <max.karavaev>
Component: miscAssignee: Mono Bugs <mono-bugs>
Status: RESOLVED FIXED QA Contact: Mono Bugs <mono-bugs>
Severity: Normal    
Priority: P5 - None CC: robertj
Version: SVN   
Target Milestone: ---   
Hardware: i686   
OS: Linux   
Whiteboard:
Found By: Beta-Customer Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: Test case project

Description Maxim Karavaev 2008-07-16 18:33:23 UTC
It seems like mishmash with /tmp/user-temp-aspnet-x/... folders in batch compilation of aspx/ascx files. All assemblies from /bin places in separately folders like 
/tmp/apache-temp-aspnet-0/15947777/assembly/shadow/3fd6f64a/cbc1ab19_f4155d53_00000001/Tercio.CMS.dll
/tmp/apache-temp-aspnet-0/15947777/assembly/shadow/56d1b77f/323223e1_31826020_00000001/NVelocity.dll

In stable 1.9.1 version this works OK.


Compilation Error

Description: Error compiling a resource required to service this request. Review your source file and modify it to fix this error.

Compiler Error Message: : ** (/usr/local/lib/mono/2.0/gmcs.exe:3113): WARNING **: The following assembly referenced from /tmp/apache-temp-aspnet-0/90b47777/assembly/shadow/56d1b77f/8271c8fb_d4a07f84_00000001/FeedbackForm.dll could not be loaded:
/portadmin/index.aspx
Show Detailed Compiler Output:

gmcs /target:library /debug- /optimize+ /warn:0 /out:"/tmp/apache-temp-aspnet-0/90b47777/App_Web_c2b49a0.dll" /r:"/usr/local/lib/mono/gac/System/2.0.0.0__b77a5c561934e089/System.dll" /r:"/usr/local/lib/mono/gac/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll" /r:"/usr/local/lib/mono/gac/System.Data/2.0.0.0__b77a5c561934e089/System.Data.dll" /r:"/usr/local/lib/mono/gac/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll" /r:"/usr/local/lib/mono/gac/System.Web/2.0.0.0__b03f5f7f11d50a3a/System.Web.dll" /r:"/usr/local/lib/mono/gac/System.Web.Services/2.0.0.0__b03f5f7f11d50a3a/System.Web.Services.dll" /r:"/usr/local/lib/mono/gac/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll" /r:"/tmp/apache-temp-aspnet-0/90b47777/assembly/shadow/56d1b77f/8271c8fb_d4a07f84_00000001/FeedbackForm.dll" /r:"/tmp/apache-temp-aspnet-0/90b47777/assembly/shadow/e8324e49/3c9231cd_d4a07f84_00000001/GoodsCatalogue.dll" /r:"/tmp/apache-temp-aspnet-0/90b47777/assembly/shadow/ee74dc13/3ad4a397_d4a07f84_00000001/ICSharpCode.SharpZipLib.dll" /r:"/tmp/apache-temp-aspnet-0/90b47777/assembly/shadow/03b043c1/d7103c45_d4a07f84_00000001/NVelocity.dll" /r:"/tmp/apache-temp-aspnet-0/90b47777/assembly/shadow/61933e2f/b53341ab_d4a07f84_00000001/Special.DBL.dll" /r:"/tmp/apache-temp-aspnet-0/90b47777/assembly/shadow/be94cbd9/6a34b45d_d4a07f84_00000001/Tercio.CMS.dll" /r:"/tmp/apache-temp-aspnet-0/90b47777/App_Web_6bdc9780.dll" /r:"/tmp/apache-temp-aspnet-0/90b47777/App_global.asax.21654831.dll"   -- "/tmp/apache-temp-aspnet-0/90b47777/App_Web_c2b49a0_0.cs" "/tmp/apache-temp-aspnet-0/90b47777/App_Web_c2b49a0_1.cs" "/tmp/apache-temp-aspnet-0/90b47777/App_Web_c2b49a0_2.cs" "/tmp/apache-temp-aspnet-0/90b47777/App_Web_c2b49a0_3.cs" "/tmp/apache-temp-aspnet-0/90b47777/App_Web_c2b49a0_4.cs" "/tmp/apache-temp-aspnet-0/90b47777/App_Web_c2b49a0_5.cs" "/tmp/apache-temp-aspnet-0/90b47777/App_Web_c2b49a0_6.cs" "/tmp/apache-temp-aspnet-0/90b47777/App_Web_c2b49a0_7.cs" "/tmp/apache-temp-aspnet-0/90b47777/App_Web_c2b49a0_8.cs" "/tmp/apache-temp-aspnet-0/90b47777/App_Web_c2b49a0_9.cs" "/tmp/apache-temp-aspnet-0/90b47777/App_Web_c2b49a0_10.cs" "/tmp/apache-temp-aspnet-0/90b47777/App_Web_c2b49a0_11.cs" "/tmp/apache-temp-aspnet-0/90b47777/App_Web_c2b49a0_12.cs" "/tmp/apache-temp-aspnet-0/90b47777/App_Web_c2b49a0_13.cs" "/tmp/apache-temp-aspnet-0/90b47777/App_Web_c2b49a0_14.cs" "/tmp/apache-temp-aspnet-0/90b47777/App_Web_c2b49a0_15.cs" "/tmp/apache-temp-aspnet-0/90b47777/App_Web_c2b49a0_16.cs" "/tmp/apache-temp-aspnet-0/90b47777/App_Web_c2b49a0_17.cs" "/tmp/apache-temp-aspnet-0/90b47777/App_Web_c2b49a0_18.cs" "/tmp/apache-temp-aspnet-0/90b47777/App_Web_c2b49a0_19.cs" "/tmp/apache-temp-aspnet-0/90b47777/App_Web_c2b49a0_20.cs" "/tmp/apache-temp-aspnet-0/90b47777/App_Web_c2b49a0_21.cs" "/tmp/apache-temp-aspnet-0/90b47777/App_Web_c2b49a0_22.cs" "/tmp/apache-temp-aspnet-0/90b47777/App_Web_c2b49a0_23.cs" "/tmp/apache-temp-aspnet-0/90b47777/App_Web_c2b49a0_24.cs" "/tmp/apache-temp-aspnet-0/90b47777/App_Web_c2b49a0_25.cs" "/tmp/apache-temp-aspnet-0/90b47777/App_Web_c2b49a0_26.cs" "/tmp/apache-temp-aspnet-0/90b47777/App_Web_c2b49a0_27.cs" "/tmp/apache-temp-aspnet-0/90b47777/App_Web_c2b49a0_28.cs" "/tmp/apache-temp-aspnet-0/90b47777/App_Web_c2b49a0_29.cs" "/tmp/apache-temp-aspnet-0/90b47777/App_Web_c2b49a0_30.cs" "/tmp/apache-temp-aspnet-0/90b47777/App_Web_c2b49a0_31.cs" "/tmp/apache-temp-aspnet-0/90b47777/App_Web_c2b49a0_32.cs" 


** (/usr/local/lib/mono/2.0/gmcs.exe:3113): WARNING **: The following assembly referenced from /tmp/apache-temp-aspnet-0/90b47777/assembly/shadow/56d1b77f/8271c8fb_d4a07f84_00000001/FeedbackForm.dll could not be loaded:
     Assembly:   Tercio.CMS    (assemblyref_index=2)
     Version:    1.6.3114.36658
     Public Key: (none)
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 (/tmp/apache-temp-aspnet-0/90b47777/assembly/shadow/56d1b77f/8271c8fb_d4a07f84_00000001).


** (/usr/local/lib/mono/2.0/gmcs.exe:3113): WARNING **: Could not load file or assembly 'Tercio.CMS, Version=1.6.3114.36658, Culture=neutral, PublicKeyToken=null' or one of its dependencies.

** (/usr/local/lib/mono/2.0/gmcs.exe:3113): WARNING **: Could not load file or assembly 'Tercio.CMS, Version=1.6.3114.36658, Culture=neutral, PublicKeyToken=null' or one of its dependencies.

** (/usr/local/lib/mono/2.0/gmcs.exe:3113): WARNING **: The following assembly referenced from /tmp/apache-temp-aspnet-0/90b47777/assembly/shadow/e8324e49/3c9231cd_d4a07f84_00000001/GoodsCatalogue.dll could not be loaded:
     Assembly:   Tercio.CMS    (assemblyref_index=2)
     Version:    1.6.3114.36665
     Public Key: (none)
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 (/tmp/apache-temp-aspnet-0/90b47777/assembly/shadow/e8324e49/3c9231cd_d4a07f84_00000001).


** (/usr/local/lib/mono/2.0/gmcs.exe:3113): WARNING **: Could not load file or assembly 'Tercio.CMS, Version=1.6.3114.36665, Culture=neutral, PublicKeyToken=null' or one of its dependencies.

** (/usr/local/lib/mono/2.0/gmcs.exe:3113): WARNING **: Could not load file or assembly 'Tercio.CMS, Version=1.6.3114.36665, Culture=neutral, PublicKeyToken=null' or one of its dependencies.

** (/usr/local/lib/mono/2.0/gmcs.exe:3113): WARNING **: Could not load file or assembly 'Tercio.CMS, Version=1.6.3114.36665, Culture=neutral, PublicKeyToken=null' or one of its dependencies.

** (/usr/local/lib/mono/2.0/gmcs.exe:3113): WARNING **: Could not load file or assembly 'Tercio.CMS, Version=1.6.3114.36665, Culture=neutral, PublicKeyToken=null' or one of its dependencies.

Unhandled Exception: System.TypeLoadException: Could not load type 'portadmin_ff_distribution' from assembly 'FeedbackForm, Version=1.2.3114.36661, Culture=neutral, PublicKeyToken=null'.
  at (wrapper managed-to-native) System.MonoType:GetMethodsByName (string,System.Reflection.BindingFlags,bool,System.Type)
  at System.MonoType.GetMethods (BindingFlags bindingAttr) [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.LookupMemberCache (System.Type t) [0x00000] 
  at Mono.CSharp.MemberCache..ctor (System.Type baseType, IMemberContainer container) [0x00000] 
  at Mono.CSharp.TypeContainer.DoDefineMembers () [0x00000] 
  at Mono.CSharp.Class.DoDefineMembers () [0x00000] 
  at Mono.CSharp.TypeContainer.DefineMembers () [0x00000] 
  at Mono.CSharp.RootContext.PopulateTypes () [0x00000] 
  at Mono.CSharp.Driver.Compile () [0x00000] 
  at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] 

Version information: Mono Version: 2.0.50727.42; ASP.NET Version: 2.0.50727.42


$ uname -a
Linux s1.bagama.ru 2.6.20-gentoo-r7 #1 SMP Wed May 2 16:43:19 MSD 2007 i686 Intel(R) Xeon(R) CPU 5140 @ 2.33GHz GenuineIntel GNU/Linux
Comment 1 Marek Habersack 2008-07-16 20:03:04 UTC
Please attach a self-contained test case which triggers the bug and reopen the report, thanks!
Comment 2 Maxim Karavaev 2008-07-16 20:22:02 UTC
It seems like bug appear when assembly with codebehind code of aspx page has dependency to other assembly. And both assemblies are not in GAC, just placed in "bin" folder.

At least after reviewing all (for about 100) our web-sites I've found this regularity.

Are you still need test case?
Comment 3 Marek Habersack 2008-07-16 20:28:39 UTC
Yes, please attach a test case. Thanks!
Comment 4 Maxim Karavaev 2008-07-17 09:39:45 UTC
It seems like situation appears when main assembly has in references second assembly with a slightly different version that placed in "bin" folder.

In which section of config file this option could be switched off (controlling exact versions)? 
It works in .Net 2.0 and previous versions of mono by default.
Now I'm investigating msdn...
Comment 5 Marek Habersack 2008-07-17 09:47:33 UTC
(In reply to comment #4 from Maxim Karavaev)
> It seems like situation appears when main assembly has in references second
> assembly with a slightly different version that placed in "bin" folder.
> 
> In which section of config file this option could be switched off (controlling
> exact versions)? 
I don't know of such a setting

> It works in .Net 2.0 and previous versions of mono by default.
> Now I'm investigating msdn...
It sounds like a runtime assembly loader bug. Please, provide a test case and we'll be able to debug it on our side. Thanks! 

Comment 6 Maxim Karavaev 2008-07-22 08:56:05 UTC
Yeah, I've catch it at last! It was a real puzzle.
See archive in attachments.

Steps to reproduce bug:
1) build both projects and run "WebSite". Everything is OK.
2) make some changes (for example, I've added "ToUpper()" to Default.aspx.cs:14) to "WebSite" and recompile this project without recompiling "RefAssembly". This changes version of "WebSite", but remains old version in refs of "RefAssembly".
3) Run "WebSite" - Compilation Error...
Comment 7 Maxim Karavaev 2008-07-22 08:57:29 UTC
Created attachment 229253 [details]
Test case project
Comment 8 Maxim Karavaev 2008-07-22 09:03:08 UTC
This bug presents in 2.0 release candidate too.
Please, if possible, backport this bug to 2.0 after fixing.

Barrel of beer to everyone who did it!! 
Comment 9 Marek Habersack 2008-07-22 13:14:34 UTC
This is some issue with the assembly loader. I tried to reproduce it outside the attached test case, but failed.
Comment 10 Andres Aragoneses 2008-07-22 13:54:19 UTC
(In reply to comment #9 from Marek Habersack)
> This is some issue with the assembly loader. I tried to reproduce it outside
> the attached test case, but failed.

Hey Marek. I think Bug 376876 is related to this, and that is easily reproducible. If we're lucky, maybe fixing that one would solve this one.
Comment 11 Robert Jordan 2008-07-22 16:12:43 UTC
Another related one: bug #394207. Unfortunately, I was not able to create a self-contained test case either.
Comment 12 Maxim Karavaev 2008-08-20 14:39:53 UTC
By the way, are there any ways to easy change version of compiled assembly? Or version of reference assembly? For example in hex-editor...

We have some old web-sites without source codes and this bug caused a lot of troubles...
Comment 13 Maxim Karavaev 2008-08-20 15:01:38 UTC
I've tried to do it in web.config:
    <runtime>
	<assemblyBinding>
	    <dependentAssembly>
		<assemblyIdentity name="Special.CMS" />
		<bindingRedirect oldVersion="1.0.2749.28356" newVersion="1.0.2774.34114"/>
	    </dependentAssembly>
	</assemblyBinding>
    </runtime>

but failed. May be mono is not support bindingRedirect...
Comment 14 Gonzalo Paniagua Javier 2008-10-07 22:26:32 UTC
Fixed in r115151.