locked
Using 32 or 64-bit DLL with AnyCPU DLL

    Question

  • Hi All,

    First of all, I'm sorry if it is not the right place for this question... It was the one I though was the most appropriate.

    I have a 3rd party DLL that has two versions, a 32 and a 64-bit version.

    I was wondering if I could create an AnyCPU DLL that would use both versions depending on the context.

    If I am in a x64 environment, I would have the two versions put in the GAC (GAC_32 and GAC_64) and my DLL put in the GAC_MSIL. Now, if I launch my DLL using a 32-bit program, will the dependency will be resolved with the 32-bit DLL? And if I launch my DLL using a 64-bit program, will the dependency will be resolved with the 64-bit DLL?

    I hope this is clear enough...

    Thank you,

    Regards,
    Tuesday, December 29, 2009 10:50 AM

Answers

  • Hi,

    You are right, Any CPU makes the dll running as either 32-bit or 64-bit.
    When the dll is launched by 64-bit program, the dll can only loads 64-bit version dependencies, if one of its dependencies has no 64-bit version, there will be an image load failed exception.
    And when the dll is launched by 32-bit program, the dll can only loads 32-bit version dependencies.


    Sincerely,
    Eric

    Please remember to mark helpful replies as answers.
    • Marked as answer by OmaR_ShaRif Wednesday, December 30, 2009 8:14 AM
    Wednesday, December 30, 2009 2:46 AM

All replies

  • Hi,

    You are right, Any CPU makes the dll running as either 32-bit or 64-bit.
    When the dll is launched by 64-bit program, the dll can only loads 64-bit version dependencies, if one of its dependencies has no 64-bit version, there will be an image load failed exception.
    And when the dll is launched by 32-bit program, the dll can only loads 32-bit version dependencies.


    Sincerely,
    Eric

    Please remember to mark helpful replies as answers.
    • Marked as answer by OmaR_ShaRif Wednesday, December 30, 2009 8:14 AM
    Wednesday, December 30, 2009 2:46 AM
  • Hi Eric,

    Thank you for your answer, that's what thought.

    Regards,
    Wednesday, December 30, 2009 8:15 AM
  • I have a questions  for you  3rd party DLL has the same name for 32 and 64 bit?

    Tuesday, August 03, 2010 10:05 AM
  • Whar happens when this 3rd party DLL  has different name for 32 and 64 bit version, for example in my case _x64.dll is the pattern for the 64 bit version. In this case the entry application can be build as Any CPU?
    Tuesday, August 03, 2010 10:07 AM