473,771 Members | 2,297 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Conditional Assembly reference

How do you conditionally reference an assembly based off of the build
configuration? Imagine a scenario where I want to have an Sql Release Server
build and an Oracle Release Build and the only difference between them is a
reference to a different assembly.

Is it possible to do this in VS2005?
Jan 13 '06 #1
7 13811
You will probably have to dynamically load the assemblies.

"Oldman" <Ol****@discuss ions.microsoft. com> wrote in message
news:4C******** *************** ***********@mic rosoft.com...
How do you conditionally reference an assembly based off of the build
configuration? Imagine a scenario where I want to have an Sql Release
Server
build and an Oracle Release Build and the only difference between them is
a
reference to a different assembly.

Is it possible to do this in VS2005?

Jan 13 '06 #2
Thanks for your response. So your saying that there isn't a way to do this.
The problem is dynamically loading the assemblies won't help me because the
source wouldn't compile unless one of the two assemblies was referenced.

"Peter Rilling" wrote:
You will probably have to dynamically load the assemblies.

"Oldman" <Ol****@discuss ions.microsoft. com> wrote in message
news:4C******** *************** ***********@mic rosoft.com...
How do you conditionally reference an assembly based off of the build
configuration? Imagine a scenario where I want to have an Sql Release
Server
build and an Oracle Release Build and the only difference between them is
a
reference to a different assembly.

Is it possible to do this in VS2005?


Jan 13 '06 #3
Well, it would help you if you wanted to code the entire thing using
reflection. Which I don't think you do.

I guess you could use reflection to create the objects, then cast them to
the appropriate interface/base class type, and reference them through that
as opposed to the actual class name.

Other then that, you just have to include all the references required for
compile.

"Oldman" <Ol****@discuss ions.microsoft. com> wrote in message
news:B5******** *************** ***********@mic rosoft.com...
Thanks for your response. So your saying that there isn't a way to do
this.
The problem is dynamically loading the assemblies won't help me because
the
source wouldn't compile unless one of the two assemblies was referenced.

"Peter Rilling" wrote:
You will probably have to dynamically load the assemblies.

"Oldman" <Ol****@discuss ions.microsoft. com> wrote in message
news:4C******** *************** ***********@mic rosoft.com...
> How do you conditionally reference an assembly based off of the build
> configuration? Imagine a scenario where I want to have an Sql Release
> Server
> build and an Oracle Release Build and the only difference between them
> is
> a
> reference to a different assembly.
>
> Is it possible to do this in VS2005?


Jan 13 '06 #4
You're touching on what I know is the right way to do this but is not
possible in my scenario. What really needs to be done is to have
interfaces/abstract classes defined in one assembly and the main application
references only that assembly.
You can then use a plugin architecture to dynamically load the correct
assembly and create the instances behind the scenes.

The problem with my scenario is I want to shove code generated obects
(strong typed datasets) into their own assemblies and there is no way it is
productive to create base interfaces for the code-generated objects.
Especially since they change so much.

This kind of stinks but it just blows this approach out of the water for
dealing with provider generic code.

What I'm really trying to do is come up with a way to get around all the
deficienices of using strong typed datasets and table adapters while trying
to talk with two different databases. It wouldn't have been ideal but it
would have been a start to just have two different kits one for Oracle
support and one for SQL Server.

The old Visual Studios (prior to .NET) also had a way to say that even a
certain file in the project should or should not be built for a particular
build configuration. This might have worked as well.

"Marina" wrote:
Well, it would help you if you wanted to code the entire thing using
reflection. Which I don't think you do.

I guess you could use reflection to create the objects, then cast them to
the appropriate interface/base class type, and reference them through that
as opposed to the actual class name.

Other then that, you just have to include all the references required for
compile.

"Oldman" <Ol****@discuss ions.microsoft. com> wrote in message
news:B5******** *************** ***********@mic rosoft.com...
Thanks for your response. So your saying that there isn't a way to do
this.
The problem is dynamically loading the assemblies won't help me because
the
source wouldn't compile unless one of the two assemblies was referenced.

"Peter Rilling" wrote:
You will probably have to dynamically load the assemblies.

"Oldman" <Ol****@discuss ions.microsoft. com> wrote in message
news:4C******** *************** ***********@mic rosoft.com...
> How do you conditionally reference an assembly based off of the build
> configuration? Imagine a scenario where I want to have an Sql Release
> Server
> build and an Oracle Release Build and the only difference between them
> is
> a
> reference to a different assembly.
>
> Is it possible to do this in VS2005?


Jan 13 '06 #5
"Oldman" <Ol****@discuss ions.microsoft. com> wrote in message
news:4C******** *************** ***********@mic rosoft.com...
How do you conditionally reference an assembly based off of the build
configuration? Imagine a scenario where I want to have an Sql Release
Server
build and an Oracle Release Build and the only difference between them is
a
reference to a different assembly.


You can just reference both in VS. Assuming you have #if ORACLE whatever
conditional compilation sections in your code, VS should optimize away the
reference to the unused one in the build. I do this all the time with
NUnit. The NUnit reference is optimized out in release builds and I do not
distribute that DLL with the apps.

-- Alan
Jan 13 '06 #6
I figured out my own question.
Although I don't see a way to do it through the IDE you can go into the
csproj file and add an attribute called Condition to the project reference.
For example, you can do the following:

<ProjectReferen ce Include="MyTest Project.csproj" Condition="
'$(Configuratio n)' == 'Oracle Release' ">
<Project>{ 7E93BE13-47DB-499F-B81F-04B19776352C} </Project>
<Name>MyTestPro ject</Name>
</ProjectReferenc e>
"Peter Rilling" wrote:
You will probably have to dynamically load the assemblies.

"Oldman" <Ol****@discuss ions.microsoft. com> wrote in message
news:4C******** *************** ***********@mic rosoft.com...
How do you conditionally reference an assembly based off of the build
configuration? Imagine a scenario where I want to have an Sql Release
Server
build and an Oracle Release Build and the only difference between them is
a
reference to a different assembly.

Is it possible to do this in VS2005?


Jan 13 '06 #7
Alan,

That is a great workaround. FYI: I did find a way to actually place a
condition on a reference but your way might be easier. See my other post if
you are interested in how to do it.

-- Chris

"Alan Pretre" wrote:
"Oldman" <Ol****@discuss ions.microsoft. com> wrote in message
news:4C******** *************** ***********@mic rosoft.com...
How do you conditionally reference an assembly based off of the build
configuration? Imagine a scenario where I want to have an Sql Release
Server
build and an Oracle Release Build and the only difference between them is
a
reference to a different assembly.


You can just reference both in VS. Assuming you have #if ORACLE whatever
conditional compilation sections in your code, VS should optimize away the
reference to the unused one in the build. I do this all the time with
NUnit. The NUnit reference is optimized out in release builds and I do not
distribute that DLL with the apps.

-- Alan

Jan 13 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
5935
by: Jouke Langhout | last post by:
Hello all! For quite some time now, I've got the following problem: Access won't close properly when a user closes the application. An ACCESS process stays active and that process can only be terminated by pressing ++ and then terminate the process. I searched the entire internet and found out that there could be two things wrong (both of them are mentioned in the bug list on the access
10
28661
by: John Smith | last post by:
After reading C# documentation the Conditional attribute seemed the way to go, but after inspecting the IL it seems those methods are still there and I imagine the CLR removes them. Using #if DEBUG means the code does not even reach the IL when compiling in release mode. Is there any benefit to using the Conditional Attribute? Am I right in thinking there will small performance overhead using over #if DEBUG.
2
2652
by: Praveen Ramesh | last post by:
Hi, Is there some kind of support for "Conditional Compilation Directives" in the aspx file? I want to enclose the Register tag as follows: #if DOTNET10 <%@ Register TagPrefix="sfwg" Namespace="CustomNameSpace" Assembly="CustomAssembly1.0"%> #else
2
2308
by: Brad | last post by:
I have one of those seemingly simple questions that evades/confuses me. I've created an assembly with bass classes (classes meant to be inherited in other assemblys). In a secondary assembly (my business layer) I created a class which inherits from a base class in the first assembly....so far so good. If I create a third assembly (my UI layer) and add reference in it to the business layer and I access a public variable in the business...
11
1925
by: Just Me | last post by:
I have a solution containing many usercontrol projects. When I wish to reference a usercontrol in another project I can select either the project or the assembly. Does it make a difference which one I select? Thanks
3
4412
by: Richard Lewis Haggard | last post by:
We are having a lot of trouble with problems relating to failures relating to 'The located assembly's manifest definition with name 'xxx' does not match the assembly reference" but none of us here really understand how this could be an issue. The assemblies that the system is complaining about are ones that we build here and we're not changing version numbers on anything. The errors come and go with no apparent rhyme or reason. We do not...
10
1861
by: lgs.lgs | last post by:
I need to be able to support multiple versions of c#. Does the compiler define any #defines so you can tell if you are compiling for.NET 1.1 or 2.0?
2
9889
by: Terry | last post by:
I am finally able to call my .Net object from a VB6 project (see posting 'Calling VB.Net classes from VB6', thanks to the reference Tony gave me to: article:http://msdn.microsoft.com/msdnmag/issues/06/05/WrapItUp/default.aspx The next step was to see if I could still use the assembly in a .Net application. I added another project to the original solution was was able to create a reference to it through the projects tab, no problems so...
14
2669
by: Monty | last post by:
Hello, I have created a solution which has both a web UI and a winform UI, the latter is just for administrators. The Web UI (a Web Application Project) and the winform project both reference the same BLL in a separate assembly, and I have all three projects in a single solution file for development, with the two UI's each having a project reference to the BLL assembly. I created a Setup and Deployment package for the winform app...
0
10260
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10102
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9910
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7460
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.