Debug and Release Assembly Refrences in XAML

In a XAML namespace declaration, is there a way to disambiguate differently named assemblies depending on your current configuration?

I'm in the process of reworking a projects build system. The old system had the debug and release assemblies building to seperate directories, which meant the following (roughly) would work fine at the top of a XAML document:

<Window x:Class="test.MainWindow"
...
    xmlns:tns="clr-namespace:TestNameSpace;assembly=SampleAssembly"
...

A request we recieved for the restructure is to differentiate our assemblies by naming them differently for Debug and Release configurations. So our SampleAssembly.dll, which was previously built in two seperate directories, is now two assemblies in the same directory, SampleAssemblyDebug.dll and SampleAssemblyRelease.dll. Is there a way to adjust that XAML line to reference the proper assembly depending on the configuration?

Answers


Currently this is not possible, without some nasty precompilation tricks. However what you can do is to define an assembly level attribute XmlnsDefinitionAttribute on your assembly and then use the uri namespace that you have defined in your XAML.

For example in your AssemblyInfo.cs file you can have something like this:

[assembly: XmlnsDefinition("http://mytest.com", "TestNameSpace")]

And then in the XAML:

<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:test="http://mytest.com">
    <Grid>
        <test:MyButton></test:MyButton>
    </Grid>
</Window>

Where MyButton is a type in the TestNameSpace namespace.


Need Your Help

Concept XML XLST preceding-sibling and ancestor

xml xslt xpath

I am very new to xslt, and found it can be easy or complex.

WinRT Event Handling from DataTemplate

winrt-xaml

I have a DataTemplate which requires an event handler for one of the objects. This DataTemplate is contained in a ResourceDictionary. What is the best way to add an event handler to this template...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.