Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jeromelaban opened this issue May 11, 2022 · 4 comments
Open

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

jeromelaban opened this issue May 11, 2022 · 4 comments
Labels
area/code-generation Categorizes an issue or PR as relevant to code generation difficulty/medium 🤔 Categorizes an issue for which the difficulty level is reachable with a good understanding of WinUI kind/bug Something isn't working

Comments

@jeromelaban
Copy link
Member

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.

@jeromelaban jeromelaban added kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. area/code-generation Categorizes an issue or PR as relevant to code generation and removed triage/untriaged Indicates an issue requires triaging or verification labels May 11, 2022
michael-hawker added a commit to CommunityToolkit/Labs-Windows that referenced this issue May 11, 2022
michael-hawker added a commit to CommunityToolkit/Labs-Windows that referenced this issue May 11, 2022
michael-hawker added a commit to CommunityToolkit/Labs-Windows that referenced this issue May 12, 2022
michael-hawker added a commit to CommunityToolkit/Labs-Windows that referenced this issue May 12, 2022
@MartinZikmund MartinZikmund added difficulty/medium 🤔 Categorizes an issue for which the difficulty level is reachable with a good understanding of WinUI and removed difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. labels Jul 25, 2023
michael-hawker added a commit to CommunityToolkit/Tooling-Windows-Submodule that referenced this issue Aug 30, 2023
Source code button navigates to component folder on GitHub (main branch)
Most likely namespace is shown (hard-coded logic for now) - unoplatform/uno#8750
Shows and links to Uwp/WinUI packages on NuGet
michael-hawker added a commit to CommunityToolkit/Tooling-Windows-Submodule that referenced this issue Aug 30, 2023
Source code button navigates to component folder on GitHub (main branch)
Most likely namespace is shown (hard-coded logic for now) - unoplatform/uno#8750
Shows and links to Uwp/WinUI packages on NuGet
michael-hawker added a commit to CommunityToolkit/Tooling-Windows-Submodule that referenced this issue Aug 30, 2023
Source code button navigates to component folder on GitHub (main branch)
Most likely namespace is shown (hard-coded logic for now) - unoplatform/uno#8750
Shows and links to Uwp/WinUI packages on NuGet
@lindexi
Copy link
Contributor

lindexi commented Jun 24, 2024

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

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

@lindexi
Copy link
Contributor

lindexi commented Jun 24, 2024

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
Copy link
Member Author

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
Copy link
Contributor

lindexi commented Jun 26, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/code-generation Categorizes an issue or PR as relevant to code generation difficulty/medium 🤔 Categorizes an issue for which the difficulty level is reachable with a good understanding of WinUI kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants