Question

In a VS Package (Visual Studio Extensibility), I have a custom extension registered (for ex ".custx") with XamlLanguageService, so that in Visual Studio when the user opens .custx, it opens up in Xaml Designer/editor just like a .xaml file.

However when I compile it as "Page" (BuildAction), the WINFX targets / Compiler errors out with the following error message.

MySample\Page1.custx : error : Markup file is not valid. Specify a source markup file with an .xaml extension.

I am looking for a solution, so that .custx pages compile as page, just like the .xaml pages in a WPF application

Any help is greatly appreciated

Was it helpful?

Solution

I would suggest simply reusing the XAML file extension (there is no way to work around this check in the targets). Is there a reason you need your own file extension?

OTHER TIPS

The fix for this issue is pretty easy. Basically I'm betting you are using a custom build action and your setting it with an integer like this:

Property property = projectItem.Properties.Item("BuildAction"); property.Value = 4; //0-3 are reserved, custom actions will be 4 or greater.

These integer values change per machine and per project type... So this error can be caused by the ItemType being set to ApplicationDefinition.

To fix this issue you need to set the ItemType to your custom action like this:

projectItem.Properties.Item("ItemType").Value = "MyCustomActionName".

Thanks

-Blake Niemyjski

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top