UserControl in same project - wpf

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.

Related

WPF User Control Library - Does not exsist in the namespace

I'm new to WPF.
I'm trying to create a WPF application with WPF User Control Library.
But when I try to build or run the project I'm getting the following errors.
I have added the reference to the starting project.
The name "HoverButton" does not exist in the namespace "clr-namespace:HomeSchool_KinectControls;assembly=HomeSchool_KinectControls;"
When I remove the Canves and other elements inside it and build, It successfully built. But when I try to use the HoverButton the error is appearing again and the project is not getting build.
I have seen it's kinda bug in the VS and I tried following:
Restarting VS
Change the Targeting Build Platform
And it doesn't work.
Please help me to find a solution.
From your code it is seen that you're trying to access the Hoverbutton from a certain library.
It is not possible to access a library without adding a reference to it.Right Click on References under the solution explorer and select Add reference. Now browse to the required library or select it if it is in GAC. It will solve your issue.

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.

Why is Visual Studio 2010's solution explorer so friggin' jumpy?

I am getting the following error on when I try to compile:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.WinFX.targets(269,9):
error MC6000: Project file must
include the .NET Framework assembly
'WindowsBase, PresentationCore,
PresentationFramework' in the
reference list.
This project is the Web backend for a Silverlight Business Application with very little modification. When I do add these references, everything breaks. I've tried removing every single reference from my references until all I had left was a reference to System. I still get the error though. In fact it is the only error that shows up.
Edit
Figured it out, and I have a new question: I accidentally moved (dragged) a XAML file from my Silverlight front-end project. Visual Studio is very finicky and will drag something at the drop of a hat. When I click an item, even if I release the mouse right away, sometimes it will drag the item following the mouse. Is there a way to make it less jumpy?
If you copied or moved an item from another project, its "Build Action" property might be set to "Page". This happened to me, and changing it to "Resource" (because that's what the item was) fixed the problem.
I've copied this answer from another site. It was the problem I was facing.
http://social.msdn.microsoft.com/Forums/en-US/msbuild/thread/7bf38ed6-43f8-492e-a304-0842e6c7c6b2/

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

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

Resources