the name <…> does not exist in the namespace clr-namespace <…>

前端 未结 25 1015
名媛妹妹
名媛妹妹 2020-11-28 04:59

I have a small WPF application which used to compile just fine but is not anymore. I can\'t really say at which point it stopped building. It just worked fine one day, and t

相关标签:
25条回答
  • 2020-11-28 05:31

    Ran into this issue today with Visual Studio 2017 Community Edition. Tried all the suggestions here (reset VS 2017, changed from x64 to x32 and back again etc etc) and from other sources to no avail. Intellisense knows everything is there but I was getting the same error everytime.

    Anyway, my fix turned out to be very simple ... aren't they always when you have spent a couple of hours on the problem!

    Basically, I did the following ...

    1. Remove offending code from xaml file (just 3 lines in my case)
    2. Build project so you get a successful build
    3. At this point the layout magically appeared in the designer window which was a good sign!
    4. Reinserted the code I removed in point 1. including the xmlns: entry
    5. At this point you shouldn't get any blue squiggles ... hopefully
    6. Build the project again

    It's seem that by getting a successful build, it must reset 'something' within VS and/or the assembly. Once you have a successful build try inserting your code again.

    0 讨论(0)
  • 2020-11-28 05:31
    • i would recommend to Rename x:Key="ViewModel" maybe there is a glitch
    • and if you type local: does VS show you HistoryViewModel?
    • also check if your Class is public
    0 讨论(0)
  • 2020-11-28 05:31

    Before adding the name space to your .xaml file, please make sure you are not having any compilation errors due to existing code.

    Once all the compilation checks are OK, then rebuild your solution and try adding the required namespace to use its class or properties.

    0 讨论(0)
  • 2020-11-28 05:32

    In addition to the "does not exist in the namespace" message, I was also getting a message from the designer that it could not display the window for x64 and ARM targets.

    I have just found that switching the build to x86 mode, doing a rebuild solution, then switching back to x64 mode and then rebuilding again fixes [both] problems.

    Simply rebuilding the x64 solution did nothing.

    0 讨论(0)
  • 2020-11-28 05:33

    I had the similar issue. In my case, I had to do the following

    • remove the referencing markup from xaml (in this example, <local:HistoryViewModel x:Key="ViewModel"/>)
    • build the Class ( in this example file which contains HistoryViewModel class )
    • Once its built, add the referencing markup in xaml
    • build again

    The above method worked for me.

    0 讨论(0)
  • 2020-11-28 05:34

    Every time it happend to me i just restarted visual studio, re-built the solution and it worked just fine.. can't say why

    0 讨论(0)
提交回复
热议问题