How to organize code using an optional assembly reference?

Posted by apoorv020 on Stack Overflow See other posts from Stack Overflow or by apoorv020
Published on 2010-06-14T07:53:36Z Indexed on 2010/06/14 8:02 UTC
Read the original article Hit count: 273

Filed under:
|
|
|

I am working on a project and want to optionally use an assembly if available. This assembly is only available on WS 2008 R2, and my ideal product whould be a common binary for both computers with and without the assembly. However, I'm primarily developing on a Windows 7 machine, where I cannot install the assembly.
How can I organize my code so that I can (with minimum changes) build my code on a machine without the assembly and secondly, how do I ensure that I call the assembly functions only when it is present.
(NOTE : The only use of the optional assembly is to instantiate a class in the library and repeatedly call a (single) function of the class, which returns a boolean. The assembly is fsrmlib, which exposes advanced file system management operations on WS08R2.)
I'm currently thinking of writing a wrapper class, which will always return true if the assembly is not present. Is this the right way to go about doing this?

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET