Importing DLLs during runtime

N

normanchong

Hi,

I'm currently developing an application for checking and doing some
configurations for another application. During those checks, I have to
access SQLServer to get configuration-info like MaxServerMemory,
MaxDegreeOfParallelism, etc

I added the references for
- Microsoft.SqlServer.ConnectionInfo and
- Microsoft.SqlServer.Smo
to my project and then imported the namespaces
- Microsoft.SqlServer.Management.Smo and
- Microsoft.SqlServer.Management.Common
and used their classes 'Server' and 'ServerConnection' to do the job

Everythink works fine, but the problem is, that the DLLs
- Microsoft.SqlServer.Replication and
- Microsoft.SqlServer.BatchParser
are now needed (and added to my project)

This wouldn't be a problem, but I wondered what happens when SQLServer
is not installed and the DLLs are missing.
Long story short: I want to get rid of the imports and do some kind of
DLL-Late-Binding, so I can react to missing DLLs within my program.
I tried to use the 'DLLImport' but I don't know much about that...So
can anyone tell me how to get the 2 classes I need (Server,
ServerConnection)?

P.S.: I'm a newbie, so keep your answers (and perhaps examples) as
simple as possible ;-)
 
G

GhostInAK

On 5 Oct 2006 01:02:31 -0700, (e-mail address removed) wrote:

First off, DllImport Will Fail, those two files are .NET assemblies -
not Win32 DLLs.

Second off, use the imports. The app will toss an exception if the
required DLLs are missing and you can then correct the problem.

-Boo
 
N

normanchong

GhostInAK said:
On 5 Oct 2006 01:02:31 -0700, (e-mail address removed) wrote:

First off, DllImport Will Fail, those two files are .NET assemblies -
not Win32 DLLs.

That's right - sorry, DllImport = stupid idea (Like I wrote: I'm a
newbie ;-) )
Second off, use the imports. The app will toss an exception if the
required DLLs are missing and you can then correct the problem.

When I start my application without those dlls, a dialog with the
exception-message appears but that doesn't seem to be the best
solution...Isn't there a way to bind the assemblies during runtime?
I tried to use
Reflection.Assembly.load(Microsoft.SqlServer.Replication) but it
doesn't seem that I can access the classes 'Server' and
'ServerConnection' with this. So I used
Reflection.Assembly.load(Microsoft.SqlServer.Smo) but that threw an
exception...

I wondered why I need the .Replication.dll \ BatchParser.dll because
the two assemblies refer to .Smo.dll \ .ConnectionInfo.dll ?!?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top