Note that there are some explanatory texts on larger screens.

plurals
  1. POXMLSerializers Dll Loading Fails with Assembly.Load(byte[] asm)
    primarykey
    data
    text
    <p>I have a strange situation in regards to xml serialization...</p> <p>If I run MyApp.exe (.NET 2.0 WinForms app) with properly generated MyApp.XMLSerializers.dll all is well and the serialization is fast (no serialization assemblies are generated at runtime, because serializers dll is found and is behaving).</p> <p>Now, if I embed MyApp.exe as a resource in MyOtherManagedApp.exe (also .net 2.0) and execute the original app from inside as follows...</p> <pre><code>pasm = System.Reflection.Assembly.Load(MyOtherManagedApp.Properties.Resources.MyAppExeBinary); Type type = pasm.GetType("MyApp.MyModule"); type.InvokeMember("Main", BindingFlags.Default | BindingFlags.InvokeMethod | BindingFlags.Static | BindingFlags.NonPublic, null, null, new object[] {args}); </code></pre> <p>... the original app loads and runs just fine, except for serialization part:</p> <ol> <li><p>If MyApp.XMLSerializers.dll is present in the working directory of MyOtherManagedApp, I get an error stating that MyApp.exe assembly cannot be found (the error is thrown by autogenerated MyApp.XMLSerializers.dll which for some strange reason, inspite of the fact that not only MyApp assembly has been loaded but is in fact executing, fails to find it).</p></li> <li><p>If MyApp.XMLSerializers.dll is NOT present in the working directory, no errors occur, but serialization assemblies are now being generated at run time which result in a big performance hit.</p></li> </ol> <p>So, my question is why does it not work as it should? Namely, why MyApp.XMLSerializers.dll works perfectly if the serialization is started by MyApp.exe when it's running by itself; whereas if it was started via Assembly.Load and InvokeMember from a different assembly, MyApp.XMLSerializers.dll complaints that it cannot find the very same MyApp assembly which has been dynamically loaded and is now running?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload