471,627 Members | 1,107 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.

using clause with a "variable" assembly

Is it possible to get c# perform a using statement where the namespace for
the using is not specified literally but instead comes from a variable, a
token, a predefined value etc.

We have numerous auto-generated assemblies that represent specific database
models within a database, but each assembly uses commonly-named base classes
with common implementations. I am writing code that deals only with the base
classes, hence it *could* be usable with any of these assemblies, but I need
a specific "using" directive to nominate a particular namespace in order to
access the base classes.

However, because our auto-generated assemblies are intended for customer
deployment, we have not tried to "break out" the base classes into a common
assembly or even a common namespace, because if the customer ever needs to
use two of our assemblies simultaneously, there might be two different
versions of the base classes involved (depending on the relative ages of the
assemblies).

Jan 18 '06 #1
2 1434
Kevin,

I think it would be a good idea if you separated out the base class and
then had your auto-generated classes derive from that.

You can not use a variable in a using statement. As it stands, without
the common base class, you have to use the full namespace qualified name, or
use the specific namespace declared in your assembly.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Kevin Frey" <ke**********@hotmail.com> wrote in message
news:ea***************@TK2MSFTNGP14.phx.gbl...
Is it possible to get c# perform a using statement where the namespace for
the using is not specified literally but instead comes from a variable, a
token, a predefined value etc.

We have numerous auto-generated assemblies that represent specific
database models within a database, but each assembly uses commonly-named
base classes with common implementations. I am writing code that deals
only with the base classes, hence it *could* be usable with any of these
assemblies, but I need a specific "using" directive to nominate a
particular namespace in order to access the base classes.

However, because our auto-generated assemblies are intended for customer
deployment, we have not tried to "break out" the base classes into a
common assembly or even a common namespace, because if the customer ever
needs to use two of our assemblies simultaneously, there might be two
different versions of the base classes involved (depending on the relative
ages of the assemblies).

Jan 18 '06 #2
So let's say I have assembly X using "base class" assembly B1, and assembly
Y using "base class" assembly B2, and B1 and B2 represent [potentially]
different generations of my base classes but have the *same* namespace,
could I actually use X and Y assemblies simultaneously within my program?

How would the compiler treat two assemblies (B1, B2) with an equivalently
named set of base classes named within the same namespace?

Thanks

Kevin

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:Oi***************@TK2MSFTNGP15.phx.gbl...
Kevin,

I think it would be a good idea if you separated out the base class and
then had your auto-generated classes derive from that.

You can not use a variable in a using statement. As it stands, without
the common base class, you have to use the full namespace qualified name,
or use the specific namespace declared in your assembly.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Kevin Frey" <ke**********@hotmail.com> wrote in message
news:ea***************@TK2MSFTNGP14.phx.gbl...
Is it possible to get c# perform a using statement where the namespace
for the using is not specified literally but instead comes from a
variable, a token, a predefined value etc.

We have numerous auto-generated assemblies that represent specific
database models within a database, but each assembly uses commonly-named
base classes with common implementations. I am writing code that deals
only with the base classes, hence it *could* be usable with any of these
assemblies, but I need a specific "using" directive to nominate a
particular namespace in order to access the base classes.

However, because our auto-generated assemblies are intended for customer
deployment, we have not tried to "break out" the base classes into a
common assembly or even a common namespace, because if the customer ever
needs to use two of our assemblies simultaneously, there might be two
different versions of the base classes involved (depending on the
relative ages of the assemblies).


Jan 19 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by \Dandy\ Randy | last post: by
1 post views Thread by G Fernandes | last post: by
2 posts views Thread by Gentian Hila | last post: by
6 posts views Thread by Nirjhar Oberoi | last post: by
11 posts views Thread by gg9h0st | last post: by
11 posts views Thread by mfglinux | last post: by
1 post views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | 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.