Question

The problem is the application refrences a solution project whose namespace has a 'System' in it. The namespace goes something like 'SolutionNamespace.WhatItIs.System'. So when I build the WPF application, its MainWindow.g.vb and Application.g.vb would give off errors like the following:

  • Type 'System.Windows.Window is undefined.
  • Type 'System.Windows.Markup.IComponentConnector

I understand that '*.g.vb' source codes are auto-generated. But is there a way to configure the generator so it could add a 'Global' to every 'System' namespaces? Or is there a way to resolve this problem? I can't really change the namespace of the other library the WPF application references since I don't own it. Any help would be appreciated.

Edit: I tried changing the SolutionNamespace.WhatItIs.System to SolutionNamespace.WhatItIs.Systems to see whether my assumptions are correct... I was wrong. System namespaces are still undefined and still asking me to change them into Global.System.

Edit II: It appears that my assumptions were correct after all. The first time I tried changing SolutionNamespace.WhatItIs.System to SolutionNamespace.WhatItIs.Systems, I did not modify its Assembly name and Root name properties. When I changed them and rebuilt, the errors were gone. Problem now is if the owner of SolutionNamespace.WhatItIs.System would allow me to change the namespace since other projects use it.

Was it helpful?

Solution

You could either try to use an alias when you add your using declarations:

using CustomSystem = SolutionNamespace.WhatItIs.System;

And then refer to those members like this:

CustomSystem.SomeClass = new CustomSystem.SomeClass();

Or just not add it to the using declarations and fully qualify each use:

SolutionNamespace.WhatItIs.System.SomeClass = 
    new SolutionNamespace.WhatItIs.System.SomeClass();

UPDATE >>>

If that doesn't help, you could take a look at the Namespace collisions and C# Namespace Alias qualifier (::) vs Dereferencing Operator (.) posts here on StackOverflow, which have good answers. I think that @Zache could be correct in mentioning that you might need to use the Global Namespace Alias.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top