VS2015 - DLL Manifest visibility in Description pane of Object Browser - wpf

I am creating a few WPF Custom Controls in VS2015 (C#) which I would like to distribute to a Shared library for other Development Team members. In order for these folks to reference the namespaces in these DLLs the preferred manner would be to use a xmlns:prefix with a URI rather than the clr-namespace syntax. I have set (in the AssemblyInfo.cs of the Custom Control) the
[assembly: XmlnsDefinition("http://www.DPACMediaSystem.com/CustomControls/", "DPACCustomControl0012.Controls")]
The developers actually use the URI and everything works ok..BUT..
I would like them to be able to see this URI in the Object Browser in the Description pane of the particular DLL.
Simple question, eventhough I can see that it exists in the manifest of the DLL through ildasm.exe, is there some setting on building the DLL that I must set to make this visible in the Object Browser ?
Any help appreciated..
Cheers,
Dezzz.

Related

WPF unable to choose right DLL if several versions are loaded within same AppDomain

We are developing plugins to be added to a giant & awesome software. We often reuse the same WPF controls so we packaged them and created separate assemblies for each of them.
Sometimes, we need to load 2 different plugins within the same instance of the software. At that point, if the 2 plugins use the same reusable control but with different DLL versions, WPF doesn't seem to be able to choose the correct one. Both DLLs are correctly loaded (seen using Process Explorer).
What we already tried :
Binding redirects
Assembly redirects
Overridden assembly resolving
Is there any solution to indicate to WPF which version of the same DLL it needs to select for requested namespace in XAML ? Could we force the use of the latest in some way (this would work for us) ?
Look at my commit o SharpDevelop: https://github.com/icsharpcode/SharpDevelop/commit/b3ea4a0efb7e3b8e083f8be40ea6f7e03ff44604
I fixed this, by using a custom "InitializComponent" Call! ("SpecialInitializeComponent") and using special merged ResourceDictionarys: VersionedAssemblyResourceDictionary! Hope that helps you!

WPF: OnApplyTemplate is not called anymore when I moved code into another DLL

Let's try to explain it clearly.
I've got a custom control built as a WPF application and it works fine. I've moved all the code into a external DLL. After this change, when I load the application, the method OnApplyTemplate() is not called any more and the control is not rendered either
I've try with Generic.xaml file is into a Themes directory (with capital T) in the root of the DLL which has the control and/or a Themes directory into the StartUp project.
If this info is important here's where I've found the control: http://www.codeproject.com/KB/WPF/WPFOutlookCalendar.aspx
The settings of the project is
Output type: Class Library
Target framework: .Net Framework 4
I've create a simple DLL project and I've added the references manually
Do you have any idea about the solution?
Thanks in advance...
The main difference between a standard Wpf Applicaton and a WPF Custom Control library are the following lines of code.
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
Adding these lines of code to your Assembly should fix your bug.
Thanks to dowhilefor, I've found the solution!
I've recreated a new library as a WPF Custom Control Library and it works.
It is a little overkill to recreate a new project so if someone can explain to me how to reconfigure an existing project, it'd be very nice ;)

The tag "xxx" does not exist in XML namespace"yyy" / Reference could not be found

I have a winform usercontrol than I want to add to wpf project.
I added the relevant references (WindowsFormsIntegration, SystemWindowsForms and my user control dll) and added this row in my XAML:
xmlns:MyControl="clr-namespace:xx.xx.xx;assembly=xx.xx"
And then this:
<WindowsFormsHost><MyControl:control></MyControl:control></WindowsFormsHost>
When I write "MyControl:" the "control" is automated show up that mean VS recognize the control and all references added ok... but when I compile the project this give me the error in the title.
Edit
Its very strange when I'm compile the all project i've got error "The type or namespace name "xx' could not be found..."
but I added all the refernces and the VS recognize the namespace so why the compiler don't found them? If this problem will be solved I beleive the other problem also will disappear.
The solution is: Go to your project properties and change the Target Framework from Client Profile to the full version of the .Net you are using, see the image below. This problem happens if your DLL targets the full .NET Framework, and your WPF Application (main project) targets .Net Client Profile.
This happened to me when I included the assembly name in the namespace definition, but both controls were in the same assembly. Just removing the assembly part of the namespace declaration solved it.
Visual Studio will load the reference only for reflection so it will show correct intellisense correctly. But in order to compile, compiler will need all the dlls that your referenced dll is dependent on. So visual studio will show intellisense for mycontrol as it can find it in reference. But your myontrol may reference other dlls which you may not have added. You will have to add dependent references of mycontrol in your project too.
It could also be that the target framework is different between your projects. We host a class library dll with the WPF pages, and it was targeted to 'Any CPU', but the host application was targeted to 'x86'. Once they matched, the problem went away.
I ran into the same "The type or namespace name 'xx' could not be found..." issue.
It disappears when I moved my Visual Studio files on a local drive. They were stored on a shared network directory before. I dont know the root cause of this, but at least I can have my designer running now.
I've encountered this problem before and replacing <MyControl:control></MyControl:control> with just <MyControl:control/> fixed it for me.
No idea why though. It seems like the first form is only for controls which can contain other controls.

IlMerge Silverlight Class Library with Custom Controls

I am trying to merge all the assemblies of an class library in a single .dll file.
I can merge all the assemblies using the Ilmerge but is that when I use the merged dll in a Silverlight application I am having trouble when a template is apply to my control and binding problems if I use a control that inherits with UserControl.
is there any solution to solve this problem?
The problem is that when the initial dlls are built the Xaml in the project is added as a resource in the dll. The code generated to load this xaml will look something like this:-
System.Windows.Application.LoadComponent(this, new System.Uri("/SilverlightLibrary1;component/MyControl.xaml", System.UriKind.Relative));
Note how the name of the dll forms part of the Uri need to fetch the xaml. I doubt IlMerge is able to spot that and fix it up. Hence once merged the Uris cannot be found.
A resolution for this is probably uglier than multiple references or simply creating another project that links all the code files involved.

Images in a WPF Custom Control Library

I need to put an image in the default view of a custom control. However, whenever I try to test the control it can't locate the image. I have tried to compile it as an embedded resource and just a plain resource in VS. Neither of these have worked. So is there a correct way to do this?
That's probably because you specified the image path as a relative path. You should use the Pack URI Scheme to specify that the resource is in the current assembly. For instance :
<Image Source="pack://application:,,,/Images/MyImage.png"/>
I have an open-source library that allows you to include country flags in your WPF application via a value converter. The flags images are stored as resources within the assembly.
It's available on NuGet:
Install-Package FamFamFam.Flags.Wpf
The source is up on GitHub:
https://github.com/drewnoakes/famfamfam-flags-wpf
You can take a look to see how the images are embedded and the Pack URI scheme is used.

Resources