When does the .NET run-time load a referenced .dll?

I ran into an interesting issue this week. We wrote a component that allows messages to be written to an IBM MQ –or- to a web service, which then writes the message to the queue for you. The reason for the web service, is that the client may not have the IBM MQ Client software installed.

So, we need to have a component that references IBM MQ, but that won’t break on a machine that doesn’t have it installed.

I was working with the consuming developer and he was saying that he was getting an error that the run-time couldn’t find the “amqmdnet.dll” reference, the main IBM MQ dll. Luckily, it was just an oversight on my part. There was a catch-block that was trying to catch MQException in the common code. That type is defined in the MQ library. So, when I removed that, it worked as expected.

In short, the run-time doesn’t actually seem to load the .dll until it has a reason to. So, it’s once you reference a type in the library, is the first time time the run-time will attempt to load it.

Posted in Best-practices, Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.


Enter your email address to follow this blog and receive notifications of new posts by email.

Join 9 other followers

%d bloggers like this: