conditional "using"

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi
How do I include DLLs based on a condition. Eg., there are 2 DLLs 'Oracle.dll' and 'SQL.dll'. I need to include ANYONE of the DLLs based on a value. Is it possile in C#
Thanks in advance
ARZ
 
ARZ said:
Hi,
How do I include DLLs based on a condition. Eg., there are 2 DLLs
'Oracle.dll' and 'SQL.dll'. I need to include ANYONE of the DLLs based on a
value. Is it possile in C#?
Thanks in advance,
ARZ

You can use conditional compilation, using a "#if SYMBOL / #endif" syntax.
However, there is not much use in conditionally using some "using"
statements,
because these do NOT include anything. A "using" directive just lets you use
a shorter name for your classes.
The real dll-include is done at the project level, with "references".

Hans Kesting
 
..Net should use these Dll's through COM interoperability by generating a
Runtime Callable Wrapper (RCW) which wraps the Dll COM interfaces with a
..Net front. This is all done for you transparently in Visual Studio - you
simply pull in the appropriate reference using the Add Reference - COM tab
into your project and the rest is done for you.

Add namespace entry

using System.Runtime.Interoperability;

then use the namespace listed in the project references to access and
instantiate the classes you want.

However, I have to question why you wish to access the Oracle.dll and
Sql.dll directly if it is for database access then you probably should be
doing this through the ADO.Net classes.





ARZ said:
Hi,
How do I include DLLs based on a condition. Eg., there are 2 DLLs
'Oracle.dll' and 'SQL.dll'. I need to include ANYONE of the DLLs based on a
value. Is it possile in C#?
 
Hi,

IT depends of how/when you decide which one you will use. if you decide it
at compile time then you should use #define #if directives. if you want to
be able to dinamically decide it then you should go for a plug-in
architecture. take a look at jon's article:
http://www.yoda.arachsys.com/csharp/plugin.html it will give you an idea of
how to do it.

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

ARZ said:
Hi,
How do I include DLLs based on a condition. Eg., there are 2 DLLs
'Oracle.dll' and 'SQL.dll'. I need to include ANYONE of the DLLs based on a
value. Is it possile in C#?
 
Back
Top