| |

VerySource

 Forgot password?
 Register
Search
View: 2105|Reply: 10

How to resolve namespace name conflicts?

[Copy link]

2

Threads

5

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 Canada

Post time: 2020-1-2 22:20:01
| Show all posts |Read mode
There are three projects, A, B, and C. A is a desktop application, B and C are 2 class libraries
The citation relationship is as follows:
Project B references C and Project A references B and C. As a result, it was reported at compile time that the namespace names in C have duplicate names and conflicts. How to solve such problems?
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-1-2 22:54:01
| Show all posts
attention,
Bangding!
Reply

Use magic Report

0

Threads

110

Posts

63.00

Credits

Newbie

Rank: 1

Credits
63.00

 China

Post time: 2020-1-2 23:12:01
| Show all posts
Since C is referenced in B, it is not necessary to directly reference B in A.
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-2 23:24:01
| Show all posts
Are there two classes with the same fully qualified names in B and C? For example, there are such definitions in B.Dll and C.Dll:

namespace MyNamespace
{
  class MyClass {}
}

If so, appropriate modifications should be made.
Reply

Use magic Report

2

Threads

5

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 Canada

 Author| Post time: 2020-1-3 11:51:02
| Show all posts
What I am talking about is actually a class dependency problem. C is a class library. Any project that needs the functions of this class library can be referenced, so projects A and B are referenced. B is a class library. Any project that needs the functions of this class library can be referenced, so A is referenced.
My current method is to modify the name, but then it is cumbersome to reuse.

Tokalian2000(SnowLover):
A quotes b for a function that requires b, and c for a function that requires c. This does not mean that b completely includes c in function, and makes another package.

Do you have any good suggestions? ? ?
Reply

Use magic Report

0

Threads

5

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-1-3 12:27:01
| Show all posts
You can use alias ~
Reply

Use magic Report

0

Threads

110

Posts

63.00

Credits

Newbie

Rank: 1

Credits
63.00

 China

Post time: 2020-1-3 14:00:01
| Show all posts
Sorry, I may have misunderstood the meaning of the landlord ..

Can you paste the general call relationship and related code?
Reply

Use magic Report

0

Threads

8

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-1-3 14:54:01
| Show all posts
A quotes b for a function that requires b, and c for a function that requires c. This does not mean that b completely includes c in function, and makes another package.


Don't understand what you mean.

If B references C, it means that B has included all C functions. It's like if your .NET application needs to run, you need the complete .NET Framework, although the functionality it provides is not related to your application, or you can split C ... don't quote it twice ...
Reply

Use magic Report

2

Threads

5

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 Invalid IP Address

 Author| Post time: 2020-1-6 19:57:01
| Show all posts
Give a simple example:
C has a database class CDatabase (assuming this name), this class completes the basic operations of the database, such as: connect, disconnect, execute SQL statements.

B is another class library that encapsulates the processing of a particular aspect of the business, which requires reading and writing database data, so a class library C is introduced in the project, so that B can use the classes in C.

A is an application that is responsible for managing the entire information system, which of course includes managing the part contained in B, so B is introduced into the project, so that the classes in B can be used. However, at some point A needs to access the database directly, so it refers to C and wants to use the classes in C to access the database.

The so-called reference is to include a dll file into the project. Found in actual use, if you do this, you will have spatial naming conflicts
Please express your opinions.
Reply

Use magic Report

1

Threads

6

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-1-6 20:48:01
| Show all posts
Bangding!
SF
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list