tags:

views:

187

answers:

3

I can load COM DLLs that are registered on my machine like this:

Type type = Type.GetTypeFromProgID("MYCOMDLL.ClassName");
object boxed = Activator.CreateInstance(type);

I can then poke around invoking methods etc.

How can I achieve this from a DLL file that is not registered on my machine?

Something like this magicode:

Type type = Type.GetTypeFromFile("MyFile.dll", "MYCOMDLL.ClassName");
object boxed = Activator.CreateInstance(type);

Is this possible?

A: 

I found this link which may have what you want:

Dynamically calling an unmanaged dll from .NET (C#)

Looks like you could wrap a helper class around it.

João Marcus
That works for unmanaged native DLL's, but if it's a COM library it won't.
Kev
Oops, you're right. I looked for alternatives, found a way to load a livrary and retrieve all the COM objects, but the activation itself seems to require the DLL to be registered.
João Marcus
+1  A: 

You either have to (a) register the DLL first in the traditional way, or (b) muck about with Registration-Free COM manifest files.

This might help with (b) - http://msdn.microsoft.com/en-us/library/ms973913.aspx

Christian Hayter
A: 

Read similar question here and look into my and author comments.

arbiter