Click here to Skip to main content
16,022,339 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I developed an application named as AAA in that application im referring an assembly named as BBB. At certain condition im loading that BBB assemby into my application using Assembly.LoadFromFile() function. Now i need to access certain object instances of AAA in BBB assembly at run time.Is it possible to accomplish this task?
Thanks in Advance
Posted

1 solution

MSIL
Hi

A solid, maintainable, and predictable  way to communicate between dynamically loaded objects is via Interfaces.

For instance AAA could implement IAAA and  BBB - IBBB.  Or a shared common interface.

When AAA loads BBB it should get the IBBB interface:

If( assembly !=  null && assembly is IBBB)
{
    IBBB oIBBB = assembly as IBBB;

    If( oIBBB != null )
    {
        oIBBB.SetIAAAProvider( this );
    }
}



The implementation in BBB will be something like this:

private IAAA OIAAA { get; set;}

void  IBBB.SetIAAAProvider ( object provider )
{
    If( provider != null && provider is IAAA )
    {
        OIAAA = provider as IAAA;
    }
}

BBB can now access AAA via its IAAA interface using OIAAA.

Hope this helps.

Regards

TwinLane
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900