简体   繁体   中英

C#. Windows Form. Partial class problem when migration from .NET 4.6.1 to 4.6.2

I try to modify Target framework from .NET 4.6.1 to 4.6.2 in Project Properties window of VS2019.

Compilation of version 4.6.1 is OK.

Compilation of version 4.6.2 fails: error CS0101: The namespace 'CoreClient' already contains a definition for 'ClientCore'.

I have 7 files with

public partial class ClienCore {}

All of the classes into the same namespace CoreClient. The error message points only to one of file from them.

For test, when I rename/delete this partial class in the file to eliminate the error, the same error points to other file from these 7 after compilation.

Image below shows Properties window of the project

My colleague found solution. The problem is hidden into files

Properties/Settings.Designer.cs

Properties/Resources.Designer.cs

ClientCore/Properties/Settings.Designer.cs

old line

  namespace CoreClient.CoreClient.Properties {

new line after fix the problem

  namespace CoreClient.Properties {

ClientCore/Properties/Resources.Designer.cs

old line

namespace CoreClient.CoreClient.Properties {
...
...
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CoreClient.CoreClient.Properties.Resources", typeof(Resources).Assembly);

new line after fix the problem

namespace CoreClient.Properties {
...
...
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CoreClient.ClientCore.Properties.Resources", typeof(Resources).Assembly);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM