none
Getting type or namespace name 'Assets' does not exist in the namespace 'LRAT'; but it does

    Question

  • When I build a WPF app, I am now getting the, "The type or namespace name 'Assets' does not exist in the namespace 'LRAT'" error. This is in the file SetManagerView.g.cs. I've deleted that file and rebuilt the solution; the error immediately comes back.

    Assets is a folder under the LRAT project. It most certainly does exist. It isn't at all obvious to me why VS 2019 (or VS 2017 for that matter) would think a folder within a project isn't there. What could be causing this?


    This could be a red herring, but I'll mention it anyway. The Assets folder has both image files (an .ico file and some .png files) plus it has some resource dictionary files in it. It doesn't seem like that would matter or cause any problems, but could I be wrong about that?


    Rod

    Friday, April 12, 2019 5:39 PM

All replies

  • Depending on where you get that error it could be that it's looking for your stuff in the exe and it isn't there.

    Because it's an old version it's looking at.

    Is something else stopping it compiling?

    Check all projects target the same .net framework.

    Are all references OK? No yellow triangles.

    Any class the same name as it's namespace?


    Hope that helps.

    Technet articles: WPF: Layout Lab; All my Technet Articles

    Friday, April 12, 2019 6:53 PM
    Moderator
  • No references have a yellow triangle next to them.

    All projects are at .NET Framework 4.5.2.

    I am getting several errors, depending upon what I have open in VS 2019. With no files open, I've got 7 errors. One of them is the, "'Assets' does not exist in the namespace 'LRAT'" that I opened this post on.

    The next is from the unit test project, which is complaining because the LRAT.exe doesn't exist. (Since the build failed, that's no surprise.)

    The remaining 5 errors are all related to the App.xaml file and they're all the same type of error, "The name … does not exist in the namespace 'clr-namespace:LRAT.<different folder here>". Here's the App.xaml file:

    <Application x:Class="LRAT.App" 
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
                 xmlns:sv="clr-namespace:LRAT.Settings.View" 
                 xmlns:vm="clr-namespace:LRAT.ViewModel" 
                 xmlns:view="clr-namespace:LRAT.View" 
                 xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
                 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
                 StartupUri="MainWindow.xaml" 
                 mc:Ignorable="d">
      <Application.Resources>
        <ResourceDictionary>
          <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/FirstFloor.ModernUI;component/Assets/ModernUI.xaml" />
            <ResourceDictionary Source="/FirstFloor.ModernUI;component/Assets/ModernUI.Light.xaml" />
            <ResourceDictionary Source="Assets/CoreFrameworkResources.xaml" />
          </ResourceDictionary.MergedDictionaries>
          <vm:ViewModelLocator x:Key="Locator" d:IsDataSource="True" />
          <x:Array x:Key="MergeTypesString" Type="sv:ComboBoxItemString">
            <sv:ComboBoxItemString ValueString="Or" />
            <sv:ComboBoxItemString ValueString="And" />
            <sv:ComboBoxItemString ValueString="Except" />
          </x:Array>
        </ResourceDictionary>
      </Application.Resources>
    </Application>


    The 4 lines that are causing errors are those starting with 

    <vm:ViewModelLocator x:Key="Locator" d:IsDataSource="True" />

    and ending with:

    <sv:ComboBoxItemString ValueString="Except" />

    It's weird as this is very much like the "'Assets' does not exist in the namespace" error, because just like that error, the folders LRAT.Settings.View and LRAT.ViewModel all exist.

    BTW, I've deleted all of the *.g.cs and *.g.i.cs files, then rebuilt the solution, in an attempt to get rid of these errors. Didn't work.

    Addendum

    I've discovered that this are even more interesting. I've been working with VS 2019. The results that I've described, previously, are from using VS 2019. I thought I would check it with VS 2017. First, I cleaned the solution within VS 2019, then closed it. Then I opened the solution using VS 2017, and cleaned it again, just to make sure. Then I rebuilt it. Doing that has eliminated 5 of the 7 errors! Why would it do that?

    The 2 errors that are left are:

    • The unit test project can't find the LRAT.exe
    • The "CS0234 The type or namespace name 'Assets' does not exist in the namespace 'LRAT' (are you missing an assembly reference?)

    Its very curious to me that there would be a difference between what VS 2017 reports and what VS 2019 reports. 

    However, if I open the App.xaml file, then I do get all 7 errors back, just as I was getting with VS 2019.


    Rod

    • Edited by Rod at Work Friday, April 12, 2019 8:28 PM more details
    Friday, April 12, 2019 7:56 PM
  • This could really be just the one error.

    That stops compilation.

    Then the stuff isn't there and the rest are raised.

    The test project is, obviously, irrelevent.

    When you build, which is the first error ( last in the list )?

    I guess it's viewmodellocator.

    This stuff presumably used to compile.

    Is it down to version of a dll the viewmodellocator depends on? ServiceLocator maybe?

    Force nuget packages refresh 


    Hope that helps.

    Technet articles: WPF: Layout Lab; All my Technet Articles

    Saturday, April 13, 2019 1:16 PM
    Moderator
  • I'm not really sure which would be the first error and which would be the last. Therefore, I've made a copy of the errors generated, when I do a Build of the solution with VS 2019:


    Rod

    Monday, April 15, 2019 3:21 PM
  • I thought I'd add more to this, in hopes that it will make it clearer what's going on. As the image in my previous post shows, there's 4 errors related to ComboBoxItemString, that all come from App.xaml, which I've previously shown in this thread.  I thought I'd show the definition of ComboBoxItemString:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;
    
    namespace LRAT.Settings.View
    {
        /// <summary>
        /// Interaction logic for SetManagerView.xaml
        /// </summary>
        public partial class SetManagerView : UserControl
        {
            public SetManagerView()
            {
                InitializeComponent();
            }
        }
    
        public class ComboBoxItemString
        {
            public string ValueString { get; set; }
        }
    }
    

    As you can see, ComboBoxItemString is a class that's defined at the same level as SetManagerView class. (Why the original developer put it there, I don't know.) And as you can see, the only thing ComboBoxItemString has is the ValueString property.

    I did look more into x:Array, which isn't something I've used before. I see that, as was done here by my colleague, this is a custom class. I found this document in Microsoft's document page, related to custom classes as used in WPF.

    I thought since ComboBoxItemString is pretty generic (as it there's nothing in it dependent upon some other class, network resource, etc.) I thought I'd pull it out of the UserControl file it was defined in. I've put it into a separate class in a Shared Project I'm working with that I've introduced in this solution. So, now here's what ComboBoxItemString looks like:

    namespace CoreShared.Common
    {
        public class ComboBoxItemString
        {
            public string ValueString { get; set; }
        }
    }
    

    It's in its own file in the folder CoreShared.Common in the Shared Project.

    Unfortunately, that didn't help. I've still got the same 7 errors, although now the 4 related to ComboBoxItemString read, "XDG0008 The name 'ComboBoxItemString' does not exist in the namespace 'clr-namespace:CoreShared.Common'."

    Now App.xaml looks like this:

    <Application x:Class="LRAT.App" 
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
                 xmlns:sv="clr-namespace:LRAT.Settings.View" 
                 xmlns:vm="clr-namespace:LRAT.ViewModel" 
                 xmlns:view="clr-namespace:LRAT.View" 
                 xmlns:sharedCommon="clr-namespace:CoreShared.Common"
                 xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
                 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
                 StartupUri="MainWindow.xaml" 
                 mc:Ignorable="d">
        <Application.Resources>
            <ResourceDictionary>
                <ResourceDictionary.MergedDictionaries>
                    <ResourceDictionary Source="/FirstFloor.ModernUI;component/Assets/ModernUI.xaml" />
                    <ResourceDictionary Source="/FirstFloor.ModernUI;component/Assets/ModernUI.Light.xaml" />
                    <ResourceDictionary Source="Assets/CoreFrameworkResources.xaml" />
                </ResourceDictionary.MergedDictionaries>
                <vm:ViewModelLocator x:Key="Locator" d:IsDataSource="True" />
                <x:Array x:Key="MergeTypesString" Type="sharedCommon:ComboBoxItemString" >
                    <sharedCommon:ComboBoxItemString ValueString="Or" />
                    <sharedCommon:ComboBoxItemString ValueString="And" />
                    <sharedCommon:ComboBoxItemString ValueString="Except" />
                </x:Array>
            </ResourceDictionary>
        </Application.Resources>
    </Application>

    I followed my colleague's style in declaring the items that comprise the x:Array MergeTypesString. I hope this makes it clearer.


    Rod

    Monday, April 15, 2019 9:35 PM

  • Hi  Rod at Work, 

    >>Unfortunately, that didn't help. I've still got the same 7 errors, although now the 4 related to ComboBoxItemString read, "XDG0008 The name 'ComboBoxItemString' does not exist in the namespace 'clr-namespace:CoreShared.Common'."

    I suggest you can upload a minimal runnable demo to us(Including your test material and remove all private information). We can download it and debugging. This will help us quickly analyze your problem.


    Best Regards

    Yong Lu

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, April 16, 2019 7:42 AM
    Moderator

  • Hi  Rod at Work, 

    >>Unfortunately, that didn't help. I've still got the same 7 errors, although now the 4 related to ComboBoxItemString read, "XDG0008 The name 'ComboBoxItemString' does not exist in the namespace 'clr-namespace:CoreShared.Common'."

    I suggest you can upload a minimal runnable demo to us(Including your test material and remove all private information). We can download it and debugging. This will help us quickly analyze your problem.


    Best Regards

    Yong Lu

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Hello Yong, where do I upload this to?

    Rod


    • Edited by Rod at Work Tuesday, April 16, 2019 8:51 PM
    Tuesday, April 16, 2019 3:34 PM
  • Hi  Rod,

    Share OneDrive files and folders:
    https://support.office.com/en-us/article/Share-OneDrive-files-and-folders-9fcc2f7d-de0c-4cec-93b0-a82024800c07

    Best Regards

    Yong Lu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, April 17, 2019 1:55 AM
    Moderator
  • Hi Yong, here's the link on my OneDrive.


    Rod

    Wednesday, April 17, 2019 2:37 PM

  • Hi   Rod at Work,

    Unfortunately, we cannot reproduce your issue on our side.


    I guess this kind of error comes with human mistakes like if we change the namespace in some improper way, or changing folder names from explorer for current project etc, where compiler is unable to detect sometimes.

    Right Click on every Project in your solution , Go to Properties and make your Default namespace as well as Default assembly name same as in your code (i.e namespace before class name)

    Check Folder names for each project by going through the explorer(Where your project solution is). If not matching with your project names, make it similar to them.

    Remove all your references from each project relevant to another of same solution, and add it again.

    Clean the whole solution again and Build The Solution.


    Best Regards

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, April 18, 2019 6:50 AM
    Moderator
  • Hello Yong,

    I am very sorry for having forgotten about the code for CoreShared. CoreShared is a Shared Project that I'm trying to use with LRAT. I've zipped it up and am sharing it on my OneDrive for you to get to. Here's the URL.


    Rod

    Friday, April 19, 2019 1:05 AM

  • Hi     Rod at Work,

    Unfortunately, I can't see your issue because of some error messages. When we ask you provide a demo to reproduce, you need to create a a minimal runnable demo which you need to remove all private information/safety information / confidential information.
     
    If there is no way to upload a demo, we can only give you an idea based on the approximate situation, you can try.

    Thank you for your understanding.

    Best Regards

    Yong Lu

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, April 19, 2019 9:18 AM
    Moderator
  • This kind of ERROR COMES FROM MICROSOFT. It is giving an error that something does not exist when clearly it does and you try to blame the user. With Moderators like you letting Microsoft away with poor quality software it won't improve and people will switch to another platform.
    Friday, April 19, 2019 10:16 AM

  • Hi     Rod at Work,

    Unfortunately, I can't see your issue because of some error messages. When we ask you provide a demo to reproduce, you need to create a a minimal runnable demo which you need to remove all private information/safety information / confidential information.
     
    If there is no way to upload a demo, we can only give you an idea based on the approximate situation, you can try.

    Thank you for your understanding.

    Best Regards

    Yong Lu

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Hello Yong,

    I'll try to get a minimal demo app that illustrates the problem that I'm having, but other issues are likely to pull me off of this. I'd really like to use Shared Projects as I see it as a very good possibility for helping us reduce duplicated code. Therefore, if you can please give me an idea as to what my problem might be, I'd really appreciate that. 

    Thank you.


    Rod

    Friday, April 19, 2019 3:23 PM