We have a managed dll that implements a public ref class derived from HwndHost in a Cpp namespace. We build a x86 version named mydll10.dll and a x64 version named mydll10_x64.dll. We are using the Cpp namespace in a WPF application in the xaml page. We are able to add the proper reference in the project using '$(Platform)' conditions. But we should use in the same page both xmlns:c="clr-namespace:Cpp;assembly=UvpProInspectWpf10" for the x86 and xmlns:c="clr-namespace:Cpp;assembly=UvpProInspectWpf10_x64" for the x64 exe. It is no possible to use any sort of #if #then #else in the xaml.
If the Cpp namespace would be in a C# project, a solution could be in the write
`myurl:"http://schemas.me.com/wpf/"
#if x64
[assembly: XmlnsDefinition(myurl, "UvpProInspectWpf10_x64")]
#else
[assembly: XmlnsDefinition(myurl, "UvpProInspectWpf10")]
#endif
Assembly.cs file and define
xmlns:c=" http://schemas.me.com/wpf/”
in the xaml. I cannot find how to do these assembly definitions in the managed C++ project. Is this possible? Of course we could break our naming rules… Thanks
Found it. Add a reference to System.Xaml.dll to the C++ managed project. Add an AssemblyInfo.cpp file with
using namespace System::Windows::Markup;
[assembly:XmlnsDefinition("http://schemas.me.com/wpf/", "Cpp")];
Then you can use in the xaml page
xmlns:c=" http://schemas.me.com/wpf/”
with the project referring to the proper x86 or x64 version
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.