views:

29

answers:

2

I would like VS2010 to ignore an error in XAML Code. The Reason is, it's not a real error, I have a own class of Windows and VS is not able to create an instance of it. So now it always shows "Can not create an instance of "ChildWindow"". This would not be bad, but it marks the hole file as error, and this looks realy ugly.

So: I would love to tell him to ignore the ChildWindow error, but show other errors, but don't know how.

Thanks for your advice.

EDIT: To make the things a bit clearer here is a sample of the code:

<cis:ChildWindow ... />
    .
    .
    .
</cis:ChildWindow>

where cis:ChildWindow is derived from UserElement. Now the preview from VS can't create an instance of childWindow and throws an errror. If I build the Project everything is fine.

A: 

You can right-click on the file in Solution Explorer and choose to Exclude it from the solution. You'll then be able to build your solution and it won't complain about errors in that file.

But that only works if you don't need to use the file to build your solution. If you need the file to be included then I'm not aware of any way to achieve what you want, other than commenting out the lines that are causing a problem (other than the obvious solution, which is to fix the actual problem, but I'm guessing there's a good reason you can't do that).

Paul Spangle
The project builds fine, only the VS-preview throws this error.
Tokk
A: 

Does ChildWindow create objects (or have a DataContext) that require external assemblies, hardware drivers, or anything unusually picky?

If so, and if you can find out which object this is through trial and error, sometimes the following works:

bool inDesignMode = System.ComponentModel.DesignerProperties.GetIsInDesignMode(this);

if(!inDesignMode)
    InitializePickyDriver();

It's worked for me a few times.

bufferz
well, indeed there are some external assemblies needed. I'll try at work tomorrow.
Tokk