[Mono-bugs] [Bug 75419][Nor] New - AppDomain does not honor
AppendPrivatePath search path.
bugzilla-daemon at bugzilla.ximian.com
bugzilla-daemon at bugzilla.ximian.com
Wed Jun 29 08:03:57 EDT 2005
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by urilith at gentoo.org.
http://bugzilla.ximian.com/show_bug.cgi?id=75419
--- shadow/75419 2005-06-29 08:03:57.000000000 -0400
+++ shadow/75419.tmp.21237 2005-06-29 08:03:57.000000000 -0400
@@ -0,0 +1,102 @@
+Bug#: 75419
+Product: Mono: Class Libraries
+Version: 1.1
+OS:
+OS Details: Gentoo
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: CORLIB
+AssignedTo: mono-bugs at ximian.com
+ReportedBy: urilith at gentoo.org
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: AppDomain does not honor AppendPrivatePath search path.
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+Description of Problem:
+
+A plug-in framework I'm writing uses AppDomain.AppendPrivatePath to specify
+additional directories the AppDomain is supposed to use to resolve
+assemblies that correspond with the directories in the framework's search
+path. Loading the dll file into a byte array, then subsequently calling
+Load on the byte array from an AppDomain fails because it cannot resolve
+the assembly.
+
+Out of curiosity, why is the AppDomain attempting to resolve the assembly
+even though the entire assembly is in the byte array?
+
+Steps to reproduce the problem:
+1. Compile an AppDomain loading app that uses runtime search path additions
+using AppendPrivatePath.
+2. Try to load an assembly within the runtime added directory.
+3.
+
+Actual Results:
+
+FileNotFoundException
+
+Expected Results:
+
+Everything works okay.
+
+How often does this happen?
+
+Every time.
+
+Additional Information:
+
+Here is the relevant code from the library:
+
+ // Loads the content of a file to a byte array.
+ protected byte[] LoadRawFile (string _filename) {
+ FileStream _fs = new FileStream (_filename, FileMode.Open);
+ byte[] _buffer = new byte [(int) _fs.Length];
+ _fs.Read (_buffer, 0, _buffer.Length);
+ _fs.Close ();
+
+ return _buffer;
+ }
+
+ protected string SearchForModule (string _name) {
+ foreach (string s in _search_path) {
+ if (Directory.Exists (s)) {
+ foreach (string f in Directory.GetFiles (s, "*.dll")) {
+ string _f = f.Replace (s, "").Replace ("/", "");
+ Console.WriteLine ("Checking {0} against {1} ({2}) (Result: {3})",
+_name, _f,
+ _f.Substring (0, _f.Length - 4), (_f.Substring (0, _f.Length - 4) ==
+_name));
+ if (_f.Substring (0, _f.Length - 4) == _name) {
+ return s + "/" + _f;
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
+( in the LoadModule method )
+
+ AppDomain _tempDomain = AppDomain.CreateDomain ("_temp_" + _name);
+
+ byte[] _raw_bytes = LoadRawFile (_filename);
+
+ // set up the search path
+ foreach (string s in _search_path) {
+ _tempDomain.AppendPrivatePath (s);
+ }
+
+ // The throw here is mostly used from dep resolver calls, although it
+should also be caught by the immediate caller
+ // (i.e. the application).
+ try {
+ _tempDomain.Load (_raw_bytes);
+ } catch (BadImageFormatException e) {
+ throw new ModuleImageException (e.Message);
+ }
More information about the mono-bugs
mailing list