can I use different references for different configurations

  • Thread starter Thread starter Atara
  • Start date Start date
A

Atara

Is there a way I can use different references for
different configurations of my project?

I have different project (and solution) configurations.
Do I have to 'Add reference' of all the dll's I use to the project, (in
all its configurations) even that some configurations does not use this
references?

e.g: version_Demo_configuration does not use the same refernces as
version_Full_product_configuration.

Thanks
Atara.
 
Atara said:
Is there a way I can use different references for
different configurations of my project?

I have different project (and solution) configurations.
Do I have to 'Add reference' of all the dll's I use to the project, (in
all its configurations) even that some configurations does not use this
references?

e.g: version_Demo_configuration does not use the same refernces as
version_Full_product_configuration.

Thanks
Atara.

Atara,

I hesitated to answer assuming someone would have provided a better
solution. Just a simple condititional compile for just 'references' is
difficult to implement because what is essentially happening when you
provdie a reference is that symbols in your code can somehow be resolved at
run/compile time. So even if you could pick and choose what it is you want
to reference - you still have to provide the alternative for any code
elements expecting a reference to 'something'.

You can use the conditional compile statements (#if ... then , #else, ..) to
block in and out various sections of code. You can also use the Conditional
attribute (System.Diagnostics.ConditionalAttribute - tho I am not sure how
that works in VB.NET - i have only used it with C#)

Instead of managing references - and trying to have a particular assembly
provide alternatives - you might be better served to manage different
assemblies that use different references.

I would think what ever stategy you choose will depend heavily on you
particular problem domain.

-ralph
 
It depends what you mean by same references?
If they are actually different references or a subset of references
then they are essentially different projects so i'd say no.

However if you just want to use different versions of the same
assembly, then you could use the configuration file and check out the
<assemblyBinding> element. That way if the user moves from Demo to
full you dont have to redeploy the whole app if it's just some of
dependant f(x)nality thats been disabled.

You can simply send out the full versions of the assemblies the main
app depends as well as a what-cha-ma-call-it, Policy thing-a-ma-jig,
which would redirect your app to use the new full versions.

Although you need to use strong naming in your assemblies to achieve
this and im not sure this is best practise. And all this assumes your
using .net refs, not COM, in which case the rules undoubtedly change.

Of course another option which might be getting right off topic, is to
go to MSDN and check out the UpdaterApplicationBlock. This is
essentially a pluggable component that allows you to update your app
across the wire.

Very cool and totally FREE.
I love that word. FREE!

hth

Richard
 
Atara,
What I would consider doing is having 2 projects, with links to the same
files.

One project has the references set one way, the second project has
references set the other way.

To create the "second" project, create an empty project, remove any files
that may be created by default. Then use 'Project - Add Existing Item' to
add your existing files (be certain to get all parts of the "file" (the .vb
& the .resx), however in the "Add Existing Item" dialog, click the down
arrow next to the Open Button & select "Link File" instead of clicking the
Open directly.

Using the "Link File" allows you to have a single copy of a file, while
sharing that file between two projects.

Alternatively, if you are using VSS, you can use VSS to share the files
between the two VSS projects, then when you work on each individual
projects, you need to remember to "get current version".

Hope this helps
Jay
 
Most of my code is the same for all configurations, but there are 3
classes (with reference to their .Net dll) that I use each of them in a
different configuration. I do not want to deploy all the dlls with all
the configurations, only the specific dlls that a specific configuration
needs.

suppose I use conditional compilation flags (#if ... #else #endif) to
block out various sections of code, but the reference list is the same.
(meanwhile, I prefer maintaining only one project)

Can I not deploy a subset of dll, or that the user will get an exception
?

Atara.
 
Atara,
Can I not deploy a subset of dll, or that the user will get an exception
?
Yes you can deploy a subset of the dll.

If your code does not try to load a DLL that is not deployed they will not
get an exception, however if your code tries to load the DLL then you will
get the exception.

HOWEVER! if you have each "configuration" in its own project, with their own
references, and each project has their own setup, I really don't see there
is any chance for a problem.

Hope this helps
Jay
 
Thank you for the advices. I will probably use the 'link file' because
it also solves the problem of different exe filenames, and different
config files.

Atara
 
Back
Top