unoplatform / uno

Open-source platform for building cross-platform native Mobile, Web, Desktop and Embedded apps quickly. Create rich, C#/XAML, single-codebase apps from any IDE. Hot Reload included! 90m+ NuGet Downloads!!
https://platform.uno
Apache License 2.0
8.81k stars 707 forks source link

`The type 'GlobalStaticResources' exists in both ...` #8750

Open jeromelaban opened 2 years ago

jeromelaban commented 2 years ago

Current behavior

When building an application, the following message may arise:

error CS0433: The type 'GlobalStaticResources' exists in both 'XXX, Version=0.0.1.0, Culture=neutral, PublicKeyToken=null' and 'XXX, Version=0.0.1.0, Culture=neutral, PublicKeyToken=null'

Expected behavior

The compilation succeeds.

How to reproduce it (as minimally and precisely as possible)

Craete an application which contains two projects that use the same default C# namespace.

Workaround

Change the default namespace to be different for each assemblies.

Works on UWP/WinUI

Yes

Environment

No response

NuGet package version(s)

4.2.6

Affected platforms

No response

IDE

No response

IDE version

No response

Relevant plugins

No response

Anything else we need to know?

This issue is caused by the fact that the code generator uses the default namespace to create the GlobalStaticResources class, and uses it in App.xaml generation to initialize resources. These types conflict because they can be found in two assemblies, with the same qualified name.

lindexi commented 3 months ago

@jeromelaban Can GlobalStaticResources be internal or other? This error is confusing. Thank you.

And I find it may hard to change to internal...

lindexi commented 3 months ago

How can I avoid this problem?

Do not have the same root namespace for two assemblies project. Please make sure that no more than one RootNamespace in your csproj[s] is the same.

jeromelaban commented 3 months ago

We do not have a fix for this yet, the only way around this is to avoid having the same default namespace for assemblies.

lindexi commented 3 months ago

@jeromelaban For me, having the same default namespace is very common. And the error messages here are confusing.