471,627 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,627 software developers and data experts.

Is this a Late Binding question?

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.

Feb 9 '06 #1
2 1085
Michael H wrote:
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/de...rp05162002.asp

--
Derrick Coetzee, MCAD, MSFT (Speech Server)
This posting is provided "AS IS" with no warranties, and confers no
rights.
Feb 13 '06 #2
On Mon, 13 Feb 2006 09:02:49 -0800, "Derrick Coetzee [MSFT]"
<dc******@online.microsoft.com> wrote:

->
-> 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/de...rp05162002.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
Feb 15 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by JD Kronicz | last post: by
9 posts views Thread by Zlatko Matiæ | last post: by
8 posts views Thread by scorpion53061 | last post: by
5 posts views Thread by eBob.com | last post: by
30 posts views Thread by lgbjr | last post: by
6 posts views Thread by Tim Roberts | last post: by
6 posts views Thread by Stephany Young | last post: by
14 posts views Thread by Siv | last post: by
4 posts views Thread by =?Utf-8?B?Y2xhcmE=?= | last post: by
1 post views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.