1

I have an issue when I create a new Custom Control in VS2015. Indeed, it generates a Themes/Generic.xaml file containing the error

"The name CustomControl does not exist in the namespace MyNamespace".

Of course, the custom control is located in the namespace MyNamespace and in the xaml file the local variable is well defined :

xmlns:local="clr-namespace:MyNamespace"

After some investigation, it appears it's a well-known bug with IntelliSense, and a simple restart should fix the problem, but it doesn't.

Related question

I tried

  • Comment and uncomment code
  • Close / Reopen the file
  • Restart Visual Studio
  • Delete all folders in %LOCALAPPDATA%\Microsoft\VisualStudio\14.0\Designer\ShadowCache
  • Switch between Debug/Release Configurations...

The error still there.

I didn't touch any line code generated by the IDE for the CustomControl, so maybe I missed something ?

using System.Windows;
using System.Windows.Controls;

namespace MyNamespace
{
    public class CustomControl : Control
    {
        static CustomControl()
        {
            DefaultStyleKeyProperty.OverrideMetadata(typeof(CustomControl), new FrameworkPropertyMetadata(typeof(CustomControl)));
        }
    }
}

Thank you.

Community
  • 1
  • 1
jbltx
  • 1,255
  • 2
  • 19
  • 34
  • Does this control exist in a different **assembly** (A different project to the one trying to use it)? Also, just try running the app, if it is referenced correctly, it will still work and clear the error. At least that's what happens when I encounter this bug. – Mike Eason Oct 12 '16 at 14:42
  • The CutomControl is on the project and not in an other assembly, so I dont't need to define explicitly the assembly name in the XAML file. However I just tried to Rebuild the Solution and that works... but the Designer panel still get the error, and the panel shows "The Design view cannot display correctly because some custom elements have not yet been built." I also tried restart again, but still there... – jbltx Oct 12 '16 at 14:53

1 Answers1

0

I finally found a workaround, it seems to be a problem related to CPU target. i was building for x64 but if I choose "Any CPU" and "Prefer 32bits", the Designer is able to find all members in namespaces. Maybe this occurs because Visual Studio is a 32bits application ? Thank you again.

jbltx
  • 1,255
  • 2
  • 19
  • 34