How to ignore an explicit error in VS2010?
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 sho开发者_StackOverflow中文版ws "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.
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.
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).
精彩评论