locked
Invalid Markup Error in VS 2012 with custom generic class

    Question

  • I'm using VS 2012 on Win8 Release  Preview. I get the following errors whenever I open the below XAML file. The Designer window displays the error "Invalid Markup". And the error list contains the following errors.

    1) The name "ViewBase" does not exist in the namespace "clr-namespace:MyViewBaseClassExample;assembly=GenericViewBaseClass".

    2) The property "TypeArguments" does not exist in the "http://schemas.microsoft.com/winfx/2006/xaml" namespace

    XAML file:

    <local:ViewBase x:Class="ViewBaseClassExample.Color"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                 xmlns:local="clr-namespace:MyViewBaseClassExample;assembly=GenericViewBaseClass"
                 x:TypeArguments="local:ColorData"
                 mc:Ignorable="d"
                 d:DesignHeight="65" d:DesignWidth="300">
        <Grid Height="100">
            <local:MySelectionUserControl x:Name="ColorFeature"/>
        </Grid>
    </local:ViewBase>

    The code behind:

        public partial class Color : ViewBase<ColorData>
        {
            public Color()
            {
                InitializeComponent();
            }
        }

    The code compiles and runs fine, but I can't see the control UI in designer. Strangely this works fine in VS 2010.
    Wednesday, August 01, 2012 1:11 AM

All replies

  • Thanks for reporting this issue. Can u please send the repro project to harikm@microsoft.com.


    Dev@Mic

    Monday, August 06, 2012 10:54 PM
  • Thanks for sending the repro to us. We can repro this on our end. The workaround is to subclass the generic type after providing the type arguments and refrain from using generic types as the root type in XAML.

    Dev@Mic

    Monday, August 13, 2012 5:31 PM
  • @HariKrishna - This workaround is not acceptable as we have about 40 classes that derive from the same generic. I don't want to create a concrete class for each of these. For now I can live with not being able to see the control in the designer. Do you know when the fix will be available ?

    Monday, August 13, 2012 6:53 PM
  • We cannot comment on the dates for future releases or updates to Visual Studio :).

    Dev@Mic

    Tuesday, August 14, 2012 7:24 PM
  • Any news on this? I just installed VS2012 and I was really hoping that this version should be better when it comes to the WPF designer.

    We have about 500 windows in our product that depends on a generic base class. This means that, until this is fixed, we have no WPF designer, instead of a bad WPF designer.

    Friday, November 09, 2012 1:48 PM
  • I have the same problem and I can't use this workaround. This is really annoying because I can't use the WPF designer in VS2012. How we can solve this problem?
    Thursday, November 22, 2012 11:00 AM
  • I'm having the exact same issue.  Works fine in VS 2010, but fails in 2012.  I thusly cannot edit the XAML visually...
    Monday, November 26, 2012 11:38 PM
  • I just heard from the product group that they will never fix this bug. Apparently they don’t give s**t about WPF and Windows development. Again, they ignore backward compatibility because they think that everyone is always creating new products. Maintenance is not a focused area; now everyone should develop Apps and HTML5…

    I can only hope that everyone that doesn’t like this register bugs on connect and premier support. Maybe if they understand how many people are affected by this…

    Wednesday, November 28, 2012 7:34 AM
  • Thanks for your feedback.

    We are actively investigating this issue, based on your feedback and will keep you posted.

    Thanks,
    Unni


    Unni Ravindranathan, Program Manager, Visual Studio and Blend This posting is provided "AS IS" with no warranties, and confers no rights.

    Thursday, November 29, 2012 7:02 AM
  • I just heard from the product group that they will never fix this bug. Apparently they don’t give s**t about WPF and Windows development. Again, they ignore backward compatibility because they think that everyone is always creating new products. Maintenance is not a focused area; now everyone should develop Apps and HTML5…

    I can only hope that everyone that doesn’t like this register bugs on connect and premier support. Maybe if they understand how many people are affected by this…

    When reading the documentation from Microsoft regarding Windows 8 related stuff I do get the same impression.

    Which su¤#s.

    Thursday, December 13, 2012 11:56 AM
  • Hi Swanberg,

                 I'm not sure where you received that information (might be a miscommunication :)). I can speak with some clarity on this as I'm a program manager in the XAML tools team and we are actively looking into fixing this for a future update to Visual Studio. If you can point me the communication , I would like to clarify this there as well. As Unni said we will keep you posted on this.


    Dev@Mic


    Friday, December 14, 2012 6:50 PM
  • Looking forward to a update from you in the near future.

    \\Stian.

    Monday, December 17, 2012 5:48 AM
  • Well, when I wrote that, it was the answer I got from your team. However, a week later I heard that you changed your mind and will investigate again whether you should fix it or not, which was welcome news. Looking forward to a positive answer.

    /Staffan

    Monday, December 17, 2012 8:24 AM
  • Hi Swanberg,

                 I'm not sure where you received that information (might be a miscommunication :)). I can speak with some clarity on this as I'm a program manager in the XAML tools team and we are actively looking into fixing this for a future update to Visual Studio. If you can point me the communication , I would like to clarify this there as well. As Unni said we will keep you posted on this.


    Dev@Mic


    I'm glad that you focus on this.

    My impression is that for the rest of MS only windows 8 apps exists. An example is Blend that comes with vs2012.

    ref this thread


    Thursday, December 20, 2012 6:45 AM
  • Staffan: I can confirm that we have added support for x:TypeArguments in WPF projects, and you should see that in the next update to Visual Studio 2012.

    Stian: We are very much committed to adding WPF, Silverlight and SketchFlow support to Blend for Visual Studio 2012 in the very near future.

    Thanks,
    Unni


    Unni Ravindranathan, Program Manager, Visual Studio and Blend This posting is provided "AS IS" with no warranties, and confers no rights.


    Thursday, December 27, 2012 11:42 PM
  • I too am encountering precisely the same issue. I've got several perhaps a dozen or so panels that will have a common genericized theme running through them. Would like to continue leveraging what we've got invested in WPF without needing to rewrite into more proven techs like WinForms (ugh!). Not good for economy Microsoft; tell me: what should I tell my boss? "Our vendor has decided to regress in their supported, if documented, support?" Would like to continue using VS2012, if that environment is the issue, but if necessary we'll just go back to VS2010.

    • Edited by mwpowellhtx Sunday, December 30, 2012 4:34 PM typo
    Sunday, December 30, 2012 4:28 PM
  • That's great news Unni. I'm looking forward to the next update.

    Wednesday, January 02, 2013 8:15 AM
  • I'm having the same issue on a project that i'm switching to VS2012.
    Do you have any idea of the release date of this update ?

    Regards,
    Nicolas


    • Edited by Nicocous1 Thursday, January 03, 2013 2:18 PM
    Thursday, January 03, 2013 10:43 AM
  • We cant give out exact release dates :). But I will update this thread as soon as the update is publicly available with the download link. 


    Dev@Mic

    Monday, January 07, 2013 8:39 PM
  • As a side note, this behaviour also shows up when the silverlight tooklit is used (e.g. when using the NumericUpDown).
    Wednesday, January 16, 2013 12:34 PM
  • The fix is now available as a part of Visual Studio Update 2 CTP 2 here

    Dev@Mic

    Wednesday, January 30, 2013 6:21 PM
  • Update 2 does not fix this
    Wednesday, February 06, 2013 5:37 PM
  • Can you please let me know the repro steps or a short snippet of the XAML you are using. Also are you using CTP1 or CTP2 of Update 2. 

    Dev@Mic

    Wednesday, February 06, 2013 7:49 PM
  • If you create a Converter in another project, reference the projects DLL

    then attempt to use it in your user control

    I'm used update vsupdate_KB2707250.exe

    I created a quick project on Google Code https://code.google.com/p/test-ctp-of-visual-studio-update-2/

    Wednesday, February 06, 2013 10:03 PM
  • I'm unable to download the sample. Can you send me the source to harikm@microsoft.com. I'm not sure if you are running into the same issue as this thread though.

    Dev@Mic

    Thursday, February 07, 2013 5:49 PM
  • Harikrishna Meno I've created a direct download for you test-ctp-of-visual-studio-update-2.zip
    Thursday, February 07, 2013 9:58 PM
  • This is primarily user error. This project does not build & run.

    You need to make the following changes.

    Refer the right assembly here  xmlns:Conv="clr-namespace:UserControlLibrary.Converters;assembly=UserControlLibrary"

    Make the converter class public.

    This will get you to build and run the project successfully.

    If you need to use the designer, then please change the platform target of the App to Any CPU \ x86.

    Both the designer process and VS are 32 bit process and we cannot load 64 bit types in them.

    I have filed a bug on my end to make sure that we display the right error on the design surface.


    Dev@Mic

    Friday, February 08, 2013 1:22 AM
  • I can confirm that this update fixes our problem, using a generic base window class. At least in the first initial test. I will continue test the rest of our cases, but it looks promising.

    /Staffan

    Friday, February 08, 2013 7:26 AM
  • I can confirm that this update fixes our problem, using a generic base window class. At least in the first initial test. I will continue test the rest of our cases, but it looks promising.

    /Staffan

    Nice. but I dont see the problem solved before the update goes live.

    Friday, February 08, 2013 8:20 AM
  • This is primarily user error. This project does not build & run.

    You need to make the following changes.

    Refer the right assembly here  xmlns:Conv="clr-namespace:UserControlLibrary.Converters;assembly=UserControlLibrary"

    Make the converter class public.

    This will get you to build and run the project successfully.

    If you need to use the designer, then please change the platform target of the App to Any CPU \ x86.

    Both the designer process and VS are 32 bit process and we cannot load 64 bit types in them.

    I have filed a bug on my end to make sure that we display the right error on the design surface.


    Dev@Mic

    Ahh yes I created the project really quick and missed the namespace assembly

    also changing the platform target of the App to Any CPU \ x86. fixed the designer issue I was having, Thanks for your help

    Friday, February 08, 2013 5:01 PM
  • Thanks for confirming.

    Dev@Mic

    Friday, February 08, 2013 6:22 PM
  • I followed this topic and when there was appeared a message about that problem has been fixed, I downloaded Update and tried it on my project one more time. Unfortunately, bug was actual. I still got "Invalid markup" error.

    Yesterday I read about new version of Visual Studio available: 2013 RC. I downloaded it, installed, and got same problem.

    So, bug is still actual.

    I tried to register microsoft account to post this message into the thread, but activation code has not been mailed to me, so I decided to write directly to you.

    You can download sample project from here http://www.sendspace.com/file/5n4mwt. It successfully builds and runs, but XAML designer fails on it, despite that older versions of Visual Studio (2008, 2010) opened it correctly.

    Please, answer if you got new information about fixing this problem.
    Wednesday, September 11, 2013 9:15 AM
  • Can you please put this on SKYDRIVE. I cannot access your link as it is marked as unsafe. Also make sure that you don't have space between your generic parameters (E.g it should be int,string not int, string).

    Dev@Mic

    Wednesday, October 02, 2013 6:13 PM