473,398 Members | 2,389 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 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 1519
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: \Dandy\ Randy | last post by:
Hello everyone. I have been following misc posts, as well as reading several FAQ's on this issue, unfortunatley I cannot locate a solution. I am hoping that someone will be able to provide me with...
1
by: G Fernandes | last post by:
Hi, can someone tell me what the following words mean as per C/clc: 1) token 2) token sequence 3) scalar variable 4) vector
2
by: Gentian Hila | last post by:
Hi, I am a beginner with Visual C++ (I am using .NET 2002) MY problem is that sometimes the main dialog class dissapears from the class view ( so if my project is named Test, I cannot see CTestDlg...
4
by: Friday | last post by:
Being an Old L.A.M.P guy, I beg you to please excuse my ignorance of dot.net (and all things Windows, for that matter). As part of an experiment (to learn enough ASP/VB.net to port a series of ...
6
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - Why doesn't the global variable "divId" always refer to the element with id="divId"?...
6
by: Nirjhar Oberoi | last post by:
Hi, Can you add two numbers using a Single Variable? :-) If yes then show me the code!!! Regards Nirjhar
11
by: gg9h0st | last post by:
i saw a code refactorying onload event listener window.onloadListeners=new Array(); window.addOnLoadListener=function(listener) { window.onloadListeners=listener; } why declare the...
11
by: mfglinux | last post by:
Hello to everybody I would like to know how to declare in python a "variable name" that it is in turn a variable In bash shell I would wrote sthg like: for x in `seq 1 3` do M$i=Material(x)...
3
by: Andrea Raimondi | last post by:
Hello peers! I'm working on this application and I'm in need for some thoughtful advice :-p I have an SQLDataSource with params, select, etc. One of my params is the table name, which can be...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.