473,666 Members | 2,382 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1538
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.co m

"Kevin Frey" <ke**********@h otmail.com> wrote in message
news:ea******** *******@TK2MSFT NGP14.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.c om> wrote in
message news:Oi******** *******@TK2MSFT NGP15.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.co m

"Kevin Frey" <ke**********@h otmail.com> wrote in message
news:ea******** *******@TK2MSFT NGP14.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
4253
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 the simple answer. My problem has to do with the leading white spaces after the first line when calling data using the @ variable. Here is my code: open (PREVIEW, "<preview.txt") or &error("Unable to open the data file for reading"); flock...
1
2355
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
1318
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 class there) and when i right click over a control and try to attach a variable to it 'add variable" is inactive. Sometimes happens since i start a new project. Sometimes after a while that I have been working on. I create the projects as Dialog...
4
2656
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 existing PHP scripts of mine to work on IIS), I have created the following simple function to compare a Website visitor's IP address against a varabe-array. The experiment invovleas a common scenario -- banning a Website visitor by IP Address: ...
6
1677
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - Why doesn't the global variable "divId" always refer to the element with id="divId"? ----------------------------------------------------------------------- Microsoft introduced a shortcut that can be used to reference elements which include an ID attribute where the ID becomes a global variable. Some browsers reproduce this behaviours but some, most...
6
2625
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
2218
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 onloadListeners, addOnLoadListener below window?
11
2248
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) #Material is a python class done
3
2838
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 programmatically set, this is necessary because I may have a simple table name or a union, hence I got to pick the correct one! Unfortunately, I can't bind this parameter to a control, session or
0
8863
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...
1
8549
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
8636
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...
0
7378
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6189
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
5661
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4192
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
2765
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
2005
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.