I have a solution containing two projects: a WPF application called "MyTest.TestApplication" and a class library called "MyTest.ClassLibrary", with corresponding default namespaces. MyTest.TestApplication has a reference to MyTest.ClassLibrary. MyTest.ClassLibrary contains a class called MyTest.ClassLibrary.TestClass. I want to add an instance of this class to the application's resources, but using a URL as the Xml namespace value.
So, I open MyTest.ClassLibrary.AssemblyInfo.cs, add a
using System.Windows.Markup
directive, and then at the very end I add the line
[assembly: XmlnsDefinition("http://schemas.test.com/test", "MyTest.ClassLibrary")]
I build the project, go to MyTest.TestApplication.App.Xaml, and I add a namespace definition to the Application element. As soon as I type xmlns:t=", I get an intellisense list of assembly names and uris, but not http://schemas.test.com/test. If I add the namespace definition anyway, like so:
xmlns:t="http://schemas.test.com/test"
and add the following to the Resources element:
<t:TestClass x:Key="myTest" />
then that resource does not get created, and the Xaml editor complains that the class TestClass does not exist in the namespace http://schemas.test.com/test.
Frustratingly, I added a default WPF Custom Control library called WpfCustomControlLibrary1, added the line
[assembly: XmlnsDefinition("bluh", "WpfCustomControlLibrary1")]
to WpfCustomControlLibrary1.AssemblyInfo.cs, built the project, referenced it in MyTest.TestApplication, and as soon as I began typing xmlns:b=" in App.xam, intellisense brings up the list of namespaces with "bluh" at the very top.
I tried adding all sorts of assemblies and using directives to MyTest.ClassLibrary, but I can't get Visual Studio to find my assembly via the schema URL. Amazingly, it does work if I set the namespace to the assembly name, like so:
xmlns:t="clr-namespace:MyTest.ClassLibrary;assembly=MyTest.ClassLibrary"
So.. what's going on here?
EDIT: Frustratingly, I finally got it to work after two hours of searching by simply removing the reference from the WPF application, and then re-adding it. Ugh. I guess this is some sort of VS2012 bug?
I think there's a problem with "ClassLibrary" as assembly name. Just spent some time now because Resharper returned
System.TypeLoadException : Could not load type 'BMN.Utils.Logging.ConfigLogger'
from assembly 'ClassLibrary, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
Changing the assembly name to BMN.Utils.Logging.UnitTests solved this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With