troubleshooting Question

Detect if DLL Reference is Valid on Client Machine

Avatar of jjsather
jjsather asked on
Visual Basic.NET
12 Comments5 Solutions433 ViewsLast Modified:

When my exe is on a client machine, I want to see if a reference in the program is valid. Mine happens to be for SMO, but it could be anything. In my project, I've added the necessary dll references. My code is follows...

Imports Microsoft.SqlServer.Management.Smo

Private Function DoesSMOExist() As Boolean
        Dim oServer As New Server() ' See if SMO dlls are even present on the machine.
        Return True
    Catch ex As Exception
        Return False
    End Try
End Function

Open in new window

I want my Try-Catch to return true or false, based on if a new object to this particular reference can be created. Instead, I get an unhandled exception that pops up a message, which I definitely want to avoid showing the users. The text is as follows...

System.IO.FileNotFoundException: Could not load file or assembly Microsoft.SqlServer.Smo, Version

Anyway, I don't need this to only work for this particular reference/object, but I want to know how to do it for *any* reference/object to determine if a client machine can handle it. I don't want to put the dlls on the client machine, nor do I want to search the registry (could be multiple places), nor do I want to see if a certain dll is in a certain location (could be multiple places).

I only want to detect if a given machine can reference (and create) a given DLL reference without popping up an ugly message.

Anyone know how to do it? Or can't it be done?

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 5 Answers and 12 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 5 Answers and 12 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros