none
Mixed mode assembly dynamic loading RRS feed

  • Question

  • Hi all,

     

    I've got an odd situation.  We have a mixed mode project.  It looks like this.

     

    MixedModeDLL depends on ManagedDLL1

    This is dependency is not by choice :P  Ideally a lot of the dependencies should have been abstracted away as an interface.  However, such is not life :)

     

    Now my question is if I simply referenced the MixedModeDLL in my project AND I replicated all the classes and namespaces that it uses in ManagedDLL1, would it work? 

    For example.  Let us suppose MixedModeDLL has a reference too

    Class foo

    {

        void bar()

        {

              Console.Writeline("I am bar from original manageddll1");

         }

    }

     

    Normally class foo lies in ManagedDLL1.

     

    I make my own ManagedDLL1 (another version) and I define bar exactly... same namespace and everything... except the implementation differs

     

    Class foo

    {

        void bar()

        {

              Console.Writeline("I am bar from THE NEW manageddll1");

         }

    }

     

    If I have an application that references MixedModeDLL and the new ManagedDLL1... would it then print "I am bar from THE NEW manageddll1"?

    I am in the process of trying this out to see if it works.  But I'd like your opinion on this...  if its even a good idea.  Do I need to match this like Assembly Identity GUIDs... or is simply matching the namespace good enough?

     

    Thanks all.

     

     

    Friday, June 25, 2010 8:52 PM

Answers

  • You need to match the assembly name (ManagedDLL1), not just the namespace and type names.  If the assembly is strong-named, you need to match a lot more: the version number, sign it with the same key, etc.

    • Marked as answer by yaminb Monday, June 28, 2010 2:36 PM
    Saturday, June 26, 2010 12:06 AM

All replies

  • You need to match the assembly name (ManagedDLL1), not just the namespace and type names.  If the assembly is strong-named, you need to match a lot more: the version number, sign it with the same key, etc.

    • Marked as answer by yaminb Monday, June 28, 2010 2:36 PM
    Saturday, June 26, 2010 12:06 AM
  • In case it helps, a term often used to describe what you are doing is "wrapper"; that is a general term without a clear definition but it might help you to find relevant articles if you use/look for that.

    Sam Hobbs; see my SimpleSamples.Info
    Sunday, June 27, 2010 11:08 AM
  • Hi,

       Just a quick reflection, if the DLL is not signed, we need to match the exact file name and the namespace and the type name and the method signature. Place it at the right place so the MixedModeDLL could find it. If it is signed, you have to sign your assembly with the same key.


    Please mark the right answer at right time.
    Thanks,
    Sam
    • Edited by SamAgain Monday, June 28, 2010 9:47 AM refine
    Monday, June 28, 2010 9:46 AM