Same class existing in multiple assemblies


B

bhattpiyush

Hi All,

I have a class Transaction in 2 different assemblies having different
namespaces totally.

I have an ASP.Net(1.1) page. In the codebehind .cs file I
references/imports one of those assemblies in using statement and use
the class from that assembly.

However this page gives compilation error as it automatically gets the
definition of this class from the other assembly which is different.

I am not referring to that assemly in any way.

I am using .Net framework 1.1

Why does the framework not use the assembly specified in the codebehind
file and associate the class with the other assembly? It even does not
give a 'Class defined in multiple places' error. Also the namespaces
are entirely different

Piyush
 
Ad

Advertisements

M

Morten Wennevik

Hi Piyush,

The namespace does not matter if you simply use Transaction in your code..
If the compiler gets confused when it finds Transaction in more than one
namespace it will give you a namespace conflict message. You say that you
get no such message so chances are the error is of another type. What
exactly is the error message?

You can always use the full name of the class including namespace or
create an alias

using MyTransaction = Namespace.Transaction;
 
B

bhattpiyush

The page gives a compilation error saying that a property does not
exist
Transaction.InstitutionId does not exist

When I use the following as suggested by you
using MyTransaction = Namespace.Transaction;
it gives me an compilation error saying 'Transaction is already
defined' whereas I don't use that dll at all

Regards
Piyush
 
J

Jianwei Sun

If I remembered correctly, the alias feature is introduced in .Net 2.0,
while the OP are using the .Net 1.1.

Morten said:
Hi Piyush,

The namespace does not matter if you simply use Transaction in your
code. If the compiler gets confused when it finds Transaction in more
than one namespace it will give you a namespace conflict message. You
say that you get no such message so chances are the error is of another
type. What exactly is the error message?

You can always use the full name of the class including namespace or
create an alias

using MyTransaction = Namespace.Transaction;


Hi All,

I have a class Transaction in 2 different assemblies having different
namespaces totally.

I have an ASP.Net(1.1) page. In the codebehind .cs file I
references/imports one of those assemblies in using statement and use
the class from that assembly.

However this page gives compilation error as it automatically gets the
definition of this class from the other assembly which is different.

I am not referring to that assemly in any way.

I am using .Net framework 1.1

Why does the framework not use the assembly specified in the codebehind
file and associate the class with the other assembly? It even does not
give a 'Class defined in multiple places' error. Also the namespaces
are entirely different

Piyush



--Happy Coding!
Morten Wennevik [C# MVP]
 
J

Jianwei Sun

You need use the full name including the namespace , like
NameSpace1.ClassA, NameSpace2.Class A ...

The page gives a compilation error saying that a property does not
exist
Transaction.InstitutionId does not exist

When I use the following as suggested by you
using MyTransaction = Namespace.Transaction;
it gives me an compilation error saying 'Transaction is already
defined' whereas I don't use that dll at all

Regards
Piyush
 
Ad

Advertisements

M

Morten Wennevik

I'm afraid you remember wrong. Alias has been around for a while.


If I remembered correctly, the alias feature is introduced in .Net 2.0,
while the OP are using the .Net 1.1.

Morten said:
Hi Piyush,
The namespace does not matter if you simply use Transaction in your
code. If the compiler gets confused when it finds Transaction in more
than one namespace it will give you a namespace conflict message. You
say that you get no such message so chances are the error is of another
type. What exactly is the error message?
You can always use the full name of the class including namespace or
create an alias
using MyTransaction = Namespace.Transaction;
Hi All,

I have a class Transaction in 2 different assemblies having different
namespaces totally.

I have an ASP.Net(1.1) page. In the codebehind .cs file I
references/imports one of those assemblies in using statement and use
the class from that assembly.

However this page gives compilation error as it automatically gets the
definition of this class from the other assembly which is different.

I am not referring to that assemly in any way.

I am using .Net framework 1.1

Why does the framework not use the assembly specified in the codebehind
file and associate the class with the other assembly? It even does not
give a 'Class defined in multiple places' error. Also the namespaces
are entirely different

Piyush
--Happy Coding!
Morten Wennevik [C# MVP]
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top