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?

2 Answers 2

2

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

Sign up to request clarification or add additional context in comments.

Comments

0

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.

2 Comments

That works for unmanaged native DLL's, but if it's a COM library it won't.
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.