Hi,
I tried to load a mixedmode dll (MC++) with AppDomain.Load(Byte[] ) in a C#
Client.
During the Load Process I got the following Exception:
System.IO.FileLoadException: Ausnahme von HRESULT: 0x80131019.
at System.Reflection.Assembly.nLoadImage(Byte[] rawAssembly, Byte[]
rawSymbolStore, Evidence evidence, StackCrawlMark& stackMark)
at System.AppDomain.Load(Byte[] rawAssembly) ...
I also tried this with a pure managed MC++ dll and got the same error.
If I load a normal C# dll everythink is fine.
Here's the code loading the Assembly:
Any Suggestions?
////////////////////////Code Snippet for Loading the Assembly
public void LoadAssemblyOnly(string Path)
{
FileStream f1 = new FileStream(Path ,FileMode.Open);
Byte[] rawAssemblyBytes1 = new Byte[f1.Length];
f1.Read(rawAssemblyBytes1,0,(int)f1.Length);
f1.Close();
AppDomain.CurrentDomain.AssemblyResolve +=new
ResolveEventHandler(CurrentDomain_AssemblyResolve0);
Assembly a.s = AppDomain.CurrentDomain.Load(rawAssemblyBytes1);
MessageBox.Show (a.s.FullName,"Loaded AssemblyName");
string AssList="";
foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies() )
{
AssList += a.FullName +"\r\n";
}
MessageBox.Show(AssList,"AssemblyList");
string typelist="";
foreach(Type t in a.s.GetTypes() )
{
typelist += t.FullName +"\r\n";
}
MessageBox.Show(typelist,"TypeLIst");
}
private Assembly CurrentDomain_AssemblyResolve0(object sender,
ResolveEventArgs args)
{
MessageBox.Show ("Name:"+args.Name,"ResolveEvent") ;
Assembly a.s = Assembly.LoadFrom(args.Name);
if(a.s!=null)
{
MessageBox.Show ("Assembly loaded:"+a.s.FullName);
}
else
{
MessageBox.Show ("Assembly not loaded");
}
return a.s;
}
////////////////////////
Best regards in advance
John
Junfeng Zhang[MSFT] - 02 Mar 2005 09:05 GMT
It is not possible to load MC++ assembly through Assembly.Load(byte[]). MC++
assembly requires fixup which cannot be performed in byte array.

Signature
Junfeng Zhang
http://blogs.msdn.com/junfeng
This posting is provided "AS IS" with no warranties, and confers no rights.
> Hi,
>
[quoted text clipped - 62 lines]
> Best regards in advance
> John