Is this a Late Binding question?

M

Michael H

Hi all,


I am trying to write code that works against Microsoft Office Primary
Interop Assemblies (PIA) and Windows Desktop Search (WDS). The problem
is, whereas I have these available on my dev machine and have written
a lot of functionality regarding these DLLs and placed them into my
own DLL to be consumed by another application, I can't know nor be
guaranteed if such Assemblies/DLLs even exist on deployed PCs. If I
try to catch the fact that the DLL isn't available, it will work
within the DLL I create, or at least it appears to, but I can create
an instance of the class that works against these missing DLLs from my
application. It seems I can't try/catch the fact that there's a
missing Assembly trying to be accessed by the functionality in the
DLL. I'm not sure that I'm explaining this very clearly so I'll type
some basic scenarios below.



1) I write a class that creates a DesktopSearch Object from the WDS
DLL. If this WDS DLL isn't on the machine, an exception occurs that I
can catch within this class I'm writing. All seems ok. I compile this
project into a DLL. I'll call this myDLL.dll

2) My main application which would like to use some of the
functionality I wrote in myDLL.dll works fine unless that WDS DLL is
missing. Now, instead of the functionality inside myDLL.dll catching
the exception and moving on, the same exception is caught in my main
application. This leads me to think the fact that the WDS DLL is
missing on a machine and there are references to it in myDLL.dll
raises an Exception in its own right.

So, I'd like to be able to just determine whether specific Assemblies
are available at runtime and write a DLL that uses some functionality
from the Assemblies if they are without causing problems when they're
not down the line when other applications consumes my DLL.
 
D

Derrick Coetzee [MSFT]

Michael said:
1) I write a class that creates a DesktopSearch Object from the WDS
DLL. [...] My main application which would like to use some of the
functionality I wrote in myDLL.dll works fine unless that WDS DLL is
missing. Now, [...] [the fact that] the WDS DLL is missing on a machine
and there are references to it in myDLL.dll raises an Exception
in its own right.

So, I'd like to be able to just determine whether specific Assemblies
are available at runtime and write a DLL that uses some functionality
from the Assemblies if they are without causing problems when they're
not down the line when other applications consumes my DLL.

Hi Michael. You are correct that any attempt to use a DLL statically
depending on DLLs which are not present will result in a runtime error, even
if the DLL itself is present. One solution is to use dynamic assembly
loading inside myDLL.dll using the Assembly.Load() method, which allows you
to invoke methods in the WDS DLL without having an explicit static
dependency on it. You can read more about dynamic assembly loading in this
MSDN sample:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp05162002.asp
 
M

Michael H

On Mon, 13 Feb 2006 09:02:49 -0800, "Derrick Coetzee [MSFT]"

->
-> Hi Michael. You are correct that any attempt to use a DLL
statically
-> depending on DLLs which are not present will result in a runtime
error, even
-> if the DLL itself is present. One solution is to use dynamic
assembly
-> loading inside myDLL.dll using the Assembly.Load() method, which
allows you
-> to invoke methods in the WDS DLL without having an explicit static
-> dependency on it. You can read more about dynamic assembly loading
in this
-> MSDN sample:
->
->
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp05162002.asp
->
-> --
-> Derrick Coetzee, MCAD, MSFT (Speech Server)
-> This posting is provided "AS IS" with no warranties, and confers
no
-> rights.



Derrick,

Thanks for the reply.. I've used this approach and it's working so
far..


Michael H.
Redmond, WA
 

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