Mixed Mode DLL???

    General discussion

  • When I try to load a mixed-mode (managed and unmanaged) dll from C# pure managed at runtime it fails.  How can I manage loading a dll file which has both managed C++/CLI and unmanaged C++ code?

    Tuesday, October 14, 2008 2:05 PM

All replies

  • I've been successful with this scenario; provide details on "it fails".
    Tuesday, October 14, 2008 3:01 PM
  • I will, but did you do any special stuff to get it working?
    Tuesday, October 14, 2008 3:28 PM
  • No more special than writing unmanaged code within a C++/CLI project.
    Tuesday, October 14, 2008 4:16 PM
  • Exactly that's what I have.  anyway i will provide more details when I finish some stuff and make sure the project at least compiles :D
    Tuesday, October 14, 2008 4:29 PM
  • Here we go...this is what I got as an unhandled exception thrown at run time complaining about the mixed mode dll.

    Could not load file or assembly 'RenderingEngine, Version=, Culture=neutral, PublicKeyToken=null' or one of its dependencies. This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem. (Exception from HRESULT: 0x800736B1)

    The DLL project consists of C++/CLI and pure unmanaged classes.  The main Dll class which is a pure C++/CLI.
    Tuesday, October 14, 2008 7:14 PM
  • I've seen that exception if the Visual C++ runtime was not installed on the target computer.
    Tuesday, October 14, 2008 7:16 PM
  • How come, other projects just run fine...

    The crash is at LoadFrom(dll);
    Tuesday, October 14, 2008 7:19 PM
  • Other C++/CLI projects, or C# projects?
    Tuesday, October 14, 2008 7:19 PM
  • Both runs fine. But the problem when I use this LoadFrom to load a DLL at runtime.  Unless it's pure managed C#, it crashes.
    Tuesday, October 14, 2008 7:22 PM
  • Is it a bug in .NET?
    Tuesday, October 14, 2008 8:30 PM
  • So no body could figure out if it's the way .NET works that does not accept anything mixed, or just me using the wrong function to load the Dll?  I'm using LoadFrom, is there any other function that can be used to load mixed Dll?  MixedLoadFrom :D?
    Wednesday, October 15, 2008 2:04 PM
  • Simply can I do that or not? Loading a mixed managed and unmanaged DLL from C# code using LoadFrom? If not, then what is the solution if there's any?

    Thursday, October 16, 2008 2:57 PM
  • Solved!
    Thursday, October 16, 2008 3:33 PM
  • Please for the solution send me an email or pm so that I can provide it.  It's a bit tricky though.  Have fun!
    Thursday, October 16, 2008 9:01 PM