Custom Silverlight control assembly not found in XAML, but is definitely referenced - silverlight

I recently added a control library project to my Silverlight app's solution, so the solution now has three projects:
SLClient
SLClient.Controls
SLClient.Web
SLClient has a project reference to SLClient.Controls, which contains the following:
Themes
Generic.xaml (contains default CustomTextBox template)
Templates.xaml (contains additional template used by CustomTextBox)
CustomTextBox.cs (Descended from System.Windows.Controls.Control)
The xaml files above have Build Action of "Resource" and an empty Custom Tool property. Everything builds fine, but when the XAML files (a view, and my App.xaml that merges in SLClient.Controls's Templates.xaml) in SLClient that reference SLClient.Controls are open, Visual Studio tells shows an error in the "xmlns:SLClient_Controls="clr-namespace:SLClient.Controls;assembly=SLClient.Controls" line:
Assembly "SLClient.Controls" was not found. Verify that you are not missing an assembly reference [...]
Update: The page not loading, which I had previously mentioned, was caused by a different error in my XAML. I still get this error though, and would still like to know what's causing it. Is it a bug in the XAML compiler? The code generated from the XAML compiles fine.

If you have added references in SLClient.Controls's project , then currently those assemblies are not automatically referenced in SLClient as expected as they do in normal .NET 2.0 projects.
So please verify that all the references in SLClient.Control's project are also manually added in SLClient project as well. For example if you add System.Windows.Toolkit reference in SLClient.Control, then you will also have to add the same reference in SLClient.
This is known bug and I have already reported this bug to Microsoft. And its still under processing.

sounds like a hokey reference. Try this:
Delete the reference in the project and the xmlns ref in the XAML.
Clean and rebuild all the projects
Re-add the project reference.
Build
Re-add the XAML xmlns reference
Rebuild
HTH,
Mark

Related

Error in Visual Studio 2017 trying to reference the WPF Extended Toolkit in XAML

I am attempting to use the WPF Extended Toolkit. I downloaded it and it is currently sitting in my project folder.
I right clicked the .dll file and checked "Unblock" following this answer. I have it referenced in my Visual Studio project.
I have it named WPF Extended Toolkit in my Toolbox.
I have the namespace in my XAML file.
When I try to use it in my XAML file, I'm getting the blue squiggly line stating, "The type toolkit:BusyIndicator was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built."
I'm very new to this, since I've only used what was available by default in WPF apps. Can someone tell me what I'm doing wrong? I thought I covered everything needed to get this going.
I figured it out! I found this answer!
Before adding the namespace, I rebuilt my project, then I added the namespace. IntelliSense picked it up and I was able to add my Busy Indicator.

UserControl in same project

I have a simple WPF Control project with 1 window and 1 custom user control. I built the project and the control showed up on the toolbox - great. I dragged a couple instances of the control onto the window and it worked as expected - great again. It added an xmlns for 'my' that referenced it's own base namespace and put in the proper references for the controls - perfect.
Then I tried to build it, not so perfect. It appears that it is looking for it's own build dll so when it starts to build the project and deletes the dll then suddenly it can't find the namespace reference so the build fails. Then the dll is missing so the designer gives the error. I can delete the reference to this namespace which fixes the error and I can rebuild successfully, which returns the dll which means I can paste the reference back in with no errors... until I try to build again...
Is there any way to do this without making every control it's own dll?
Don't do a rebuild on release?
Designer errors don't stop my compiles. But the designer error doesn't go away until release is built.
Check your build settings.

Silverlight Designer not finding custom controls

I'm having an issue where silverlight doesn't recognise custom controls or resources.
I include the namespace and intelisense recognises the item, the application builds fine and runs fine however the designer throws the following error.
The type 'x' was not found. Verify that you are not missing an assembly reference
and that all referenced assemblies have been built.
Usually I'm able to sort out the issue by performing a clean/rebuild of the project. however recently this route has been unable to resolve the issue.
Is this a known issue with the Visual Studio designer? are there any fixes/work arounds out there?
Thanks
EDIT:
I'm using the following declaration:
xmlns:converters="clr-namespace:x.Classes.Converters"
and referencing the control using the following:
<converters:ReportTypeImageConverter x:Name="ReportTypeImage"/>
Restarted visual studio this morning when I logged in and now its recognising the controls, which means I can use the designer again.
Try to go to your Project Properties and put some Reference Paths(folders where you .dll are)
Hope it Helps

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.

Resources