[Mono-dev] Incorrect cultured SatelliteAssembly

Armand du Plessis armand at dotnet.org.za
Mon Dec 18 08:28:57 EST 2006


Came across a small problem when loading satellite assemblies for a
specific Assembly.

>From MSDN Assembly.GetSatelliteAssembly should throw
System.IO.FileLoadException when the satellite assembly is found but
the culture don't match ie. If U.S. English (en-us) satellite assembly
is requested but culture "English" is found in the expected location
(/en-us) then FileLoadException should be thrown instead of returning
found assembly with incorrect culture.

I've attached a test case for above mentioned scenario and a possible
patch, however the patch will still causes the incorrect assembly to
be loaded into the AppDomain which is different from behavior on
Microsoft who don't load the assembly if the culture is incorrect. I
assume a better place for this check would be in the LoadAssembly
internal call?



PS. The attached test case is zipped as it contains embedded mock
assemblies which bloats the test file quite a bit.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: AssemblyTestFixture.zip
Type: application/zip
Size: 11826 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20061218/cc9152c6/attachment.zip 
-------------- next part --------------
Index: Assembly.cs
--- Assembly.cs	(revision 69656)
+++ Assembly.cs	(working copy)
@@ -422,7 +422,14 @@
 			aname.CultureInfo = culture;
 			aname.Name = aname.Name + ".resources";
-			return Load (aname);
+            Assembly satellite = Load (aname);            
+            AssemblyName satelliteName = satellite.GetName();
+            if (satelliteName.CultureInfo == culture)
+                return satellite;
+            throw new FileLoadException("Satellite assembly with matching name found, culture did not match the one specified");
 		[MethodImplAttribute (MethodImplOptions.InternalCall)]

More information about the Mono-devel-list mailing list