none
Reflection to load dependent dll's RRS feed

  • Question

  • My c# application exe is running in c:\MyApplication folder .

    I am using reflection to load dll "A" and display collection of values .

    Assembly appAssembly = null;
    appAssembly = Assembly.LoadFrom("c:\Dll\A.dll");

    Then i use the methods in A.dll to assign data to a datatable. But there are empty values coming in one column.

    I am getting proper values when i set my exe to run in C:\Dll folder. Hence i found that there is some dependency dll in c:\Dll responsible for showing proper values. 

    I found that "B.dll" is dependency dll and when added in c:\MyApplication folder gives me data properly.

    I should not be adding "B.dll" to application directory because this would mean i add a direct reference of the DLL in my project.

    My code is supposed to use  reflection to load the dll types and i am not sure how will i refer B.dll in my application at runtime so that i get proper values from A.dll methods. 

    Wednesday, November 26, 2014 9:11 AM

Answers

  • Hello battech,

    >>My code is supposed to use  reflection to load the dll types and i am not sure how will i refer B.dll in my application at runtime so that i get proper values from A.dll methods.

    Do you mean that the A.dll is dependent on B.dll? If it is, you could use the AppDomain.AssemblyResolve Event to load the requesting assembly and its dependencies.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, November 27, 2014 5:30 AM
    Moderator