Hi
I am facing a problem while using function CreateInstanceFromAndUnwrap(....) in my program.
Problem:
I do have certain c# dll which i have to load in my c++/cli code.and after that i want to call certain function from that assembly. For example, I do have a dll(C#) in my C:\ drive.This dll contain a class say ABC.
I want to call certain properties,methods on the object of ABC.
//my sample code part 1 for AppDomain::CreateInstanceFromAndUnwrap
//New app domain is created
AppDomainSetup^ appDomainInfo = gcnew AppDomainSetup();
appDomainInfo->ApplicationBase = strDefaultPath;//Path of dll(c#)
AppDomain^ newAppDom = AppDomain::CreateDomain(strDomainName,nullptr,appDomainInfo);
Object^ obj = newAppDom->CreateInstanceFromAndUnwrap(strPath,strClassName );//Line 4
Type^ tAsmbly = obj->GetType();
String^ sFullName = tAsmbly->AssemblyQualifiedName;
PropertyInfo^ pInfo = tAsmbly->GetProperty("AddInType");//property not found
String^ sTypeName = (String^)pInfo->GetValue(obj,nullptr);
//my sample code part 2 for Assembly::LoadFrom
Assembly^ asm = Assembly::LoadFrom(strPath);
Object^ obj = asm->CreateInstance(strClassName);
Type^ tAsmbly = obj->GetType();
String^ sFullName = tAsmbly->AssemblyQualifiedName;
PropertyInfo^ pInfo = tAsmbly->GetProperty("AddInType");//Property Found
String^ sTypeName = (String^)pInfo->GetValue(obj,nullptr);
In part 1 i cant typecast the object with the class name because it is in only in string format.
Note:
In part 1 sFullName is System.MarshalByRefObject, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.
In part 2 sFullName is Actual full name not like above part 2
Question: I just want to know can I get the Same full name in both part. I mean in part 1 I want to get the actual assembly full name. I cant type cast it to the desired class so I need some thing by reflection I guess.
Thanks