Krishna,
The following sample is from a VB.NET project I just deployed.
Unfortunately it is not in C++ but perhaps you can glean some ideas.
IReport is an abstract interface I defined that is known by the the caller
and is implemented by the dynamically loaded assembly.
Friend Class ReportProxy
Friend ReportAssembly As String
Friend ReportNamespace As String
Public Function Report() As IReport
Dim hdl As System.Runtime.Remoting.ObjectHandle
hdl = Activator.CreateInstance(ReportAssembly, ReportNamespace)
Return CType(hdl.Unwrap, MyCom.General.Reporting.IReport)
End Function
End Class
"KK" <kr*****@lucidindia.net> wrote in message
news:es**************@TK2MSFTNGP11.phx.gbl...
Hi all
Can anybody help me what's going wrong here and how to correct it.
Code is as follows....
System::Object * GetObjectFromAssembly()
{
Assembly * pMyAssembly = Assembly::Load("MyAssembly");
Type * pMyType = pMyAssembly->GetType("MyNameSpace.MyClass");
System::Object * pRet = pMyType->CreateInstance();
pMyAssembly = 0;
return pRet;
}
Here i'm getting the error as "pRet is disposed." How to create object
from Assembly at runtime and use it?
Thanks and Regards
Krishna