question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

My WPF project has a namespace error

See original GitHub issue

Error Tip: No type or namespace name “Windows” in namespace “test.wpf.system” (missing assembly reference?)

This error occurs when my project contains the System namespace. I predict this is due to the implicit namespaces of.net6. I tried <DisableImplicitNamespaceImports>true</DisableImplicitNamespaceImports> and <Using Remove="XXX.System" /> but it didn’t work.

image

Repeat steps: build project

Error Code: https://github.com/344089386/WpfTest

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
miloushcommented, Oct 11, 2022

@chris-kruining correct, in this specific case - where the generated system types get “hijacked” - would be resolved if the generator used the global alias. In your case though, that would not help, because the window itself is already in a conflicting namespace.

0reactions
chris-kruiningcommented, Oct 11, 2022

I don’t think this has anything to do with implicit usings. You are introducing Test.Wpf.System namespace in UserInfo.cs and your window is in the Test.Wpf namespace. All System namespaces then resolve to Test.Wpf.System which has precedence.

So don’t do that. Technically you could argue that the code generator should use global namespace alias, though I think you would have to present a compelling justification for such change.

@miloush Wouldn’t this issue be resolved if the code generator applies the global:: prefix if a assembly is passed via the attribute? this related to my issue in #7173

Read more comments on GitHub >

github_iconTop Results From Across the Web

The name does not exist in the namespace error in XAML
When you are writing your wpf code and VS tell that "The name ABCDE does not exist in the namespace clr-namespace:ABC".
Read more >
namespace collision in clr-namespace #7173 - dotnet/wpf
It seems to me that the generated g code in the obj folder is what is causing the naming collision between my referenced...
Read more >
The type or namespace name 'System' could not be found
When I try to create a new Xamarin Forms app, nothing works. No imports can be found. Almost every line in the autogenerated...
Read more >
Compiler Error CS0246
The type or namespace name 'type/namespace' could not be found (are you missing a using directive or an assembly reference?) A type or...
Read more >
wpf namespace error message..!!!
If your project has never been compiled, then the class isn't found. Try closing all XAML windows and correcting possible errors preventing a ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found