up vote 2 down vote favorite

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?

link|flag

78% accept rate

3 Answers

up vote 1 down vote accepted

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

link|flag
up vote 0 down vote

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.

link|flag
That works for unmanaged native DLL's, but if it's a COM library it won't. – Kev Jun 26 '09 at 15:55
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 Jun 26 '09 at 19:18
up vote 0 down vote

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

link|flag

Your Answer

 
get an OpenID
or
never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.