Yes, that is what I have to do. But I want to know if it is possible to add
another assembly into current running assembly? then I can refer that data
type in current running assembly.
Please forgive me if I am not understanding you correctly. The current
running Assembly can use a public type in another Assembly by using either
Activator.CreateInstance() of Assembly.Load().
I tried this, supposing I used VC++ to create an OCX call MyOCX, and there
is a object in the OCX call MyObject. I used the AxImp.exe to generate the
proxy assembly call MyOCXLib.dll. Now in my code
Assembly myAssembly = Assembly.LoadFrom("MyOCXLib.dll");
Type myObjType = myAssembly.GetType("MyOCXLib.MyObject");
MyOCXLib.MyObject myObj =
(MyOCXLib.MyObject)Activator.CreateInstance(myObjType);
// the above line will cause an exception to be thorwn with error message
"specified cast in invalid"
// If I change to the following line
MyOCXLib.MyObject myObj =
(MyOCXLib.MyObject)Activator.CreateInstance(typeof(MyOCXLib.MyObject));
// then it is ok.
that is the problem. do you know why? I think the MyOCXLib.MyObject type
does not exist in the current Assembly. What do you think?
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.