none
Couldn't load assemblies "xyz.dll" and it's dependencies dynamically in C# WCF RRS feed

  • Question

  • Hi All,

    I am working on client services (wcf) application. I have to perform encryption and decryption through secure Safenet third party application​. Secure safenet third party application​ provides 2 dlls for encryption and decryption i.e.ingdnp.dll and KeyRSAheader.dll. We have created a custom class library called SafenetApp. We added inbuilt Safenet client dlls I.e. ingdnp.dll and KeyRSAheader.dll in SafenetApp project and added wrapper functions for encryption and decryption in one class called CryptoUtils in SafenetApp project.

    To achieve encryption and decryption in Utility at service side of project, 

    1. We want to load SafenetApp.dll, ingdnp.dll and KeyRSAheader.dll dynamically in Utility library at service side. We used Assembly.load(dll path) to load these 3 assemblies.We are loading mentioned 3 dlls one by one.

    2. Once these dlls get loaded, we need to create object of CryptoUtils class from SafenetApp.dll through reflection. But it shows couldn't load assemblies "SafenetApp.dll" and it's inner exception is "Couldn't load dependent assemblies KeyRSAHeader.dll".

    Do I need to load all assemblies or only one i.e. SafenetApp.dll ?

    Do I missed something ? Please suggest me solution. TIA.

    • Moved by Sabah ShariqMVP Monday, September 25, 2017 11:21 AM Moved From Visual C#
    Sunday, September 24, 2017 5:00 AM

All replies

  • 1. We want to load SafenetApp.dll, ingdnp.dll and KeyRSAheader.dll dynamically in Utility library at service side. We used Assembly.load(dll path) to load these 3 assemblies.We are loading mentioned 3 dlls one by one.

    Why? Why doesn't the WCF service project not have reference to the Utility.DLL, the Utility.DLL have reference to the other DLL(s) and with them all in the Bin folder with all the other DLL(s) so .NET can find them at runtime? 

    Sunday, September 24, 2017 11:22 AM
  • Hi DA924x,

    We want to perform encryption and decryption only if Safenet third party client is installed on machine. We are referring to regitry to check if safenet client is installed or not.

    1. If it is installed, we want to load these assemblies dynamically and achieve the encryption and decryption. 

    2. If it is not installed, we don't to perform encryption and decryption. We will return plain text what we received.

    Thanks.

    Sunday, September 24, 2017 12:23 PM
  • I would say post to the WCF forum for help.

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=wcf

    Sunday, September 24, 2017 1:07 PM
  • Hi Sud,

    To check whether it is related with KeyRSAheader.dll, I suggest you create a custom class library and then load it dynamically, will it throw error?

    To check whether it is related with dynamically loading, I suggest you add these three dlls directly to service project, will it throw any error?

    To check whether it is specific to WCF Project, I suggest you create a console application and then load the dll dynamically, will it work?

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, September 26, 2017 2:33 AM