Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / CLR / March 2005

Tip: Looking for answers? Try searching our database.

AppDomain.Load MixedMode (MC++) Dll Problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John - 01 Mar 2005 21:07 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.