Intillisense fails on undefined namespace in XAML on Visual Studio 2010 - wpf

I must be brain dead. I have tried for six hours now (with Google) and can not solve this very very simple problem.
In Visual Studio 2010, I created a project. (right-click on solution, Add new project...).
Inside the new project, I created a new folder of name Helpers. To the folder I added a class for a converter.
Inside the project, I added a new XAML window (in WPF). The Target Framework is .Net Framework 4.0
Everything has been built (multiple times) without compilation errors. The platform target build for the project is X86.
The problem: Intellisense does not see the namespace for the class under the Helpers folder and so the Visual Designer fails. The namespace in the Helpers folder is:
Chaos.UI.Helpers
and trying to reference this namespace in the XAML like:
xmlns:converters="clr-namespace:Chaos.UI.Helpers"
ofcourse results in the dreaded:
Undefined CLR namespace. The 'clr-namespace' URI refers to a namespace 'Chaos.UI.Helpers' that is not included in the assembly.
These are clean files in the same project. The only added code is in the converter class contained in the Chaos.UI.Helpers namespace.
How do I fix this? (I need the designer to work).
Anybody, Plz help

Try use assembly
xmlns:converters="clr-namespace:Chaos.UI.Helpers;assembly=Chaos.UI"

Related

How to avoid XAML namespace import in every Window

Is it somehow possible to avoid xmlns:Engine="clr-namespace..." if i need the same namespace in each of my application windows?
Thanks
I'm agree with HCL, I think it can't be done and adding the namespace will not consume more resources.
I will give you an alternative. You can change the the window template (or create one of your own) to make it include the namespace for you.
In my computer, for VS2010, the path of the template is:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ItemTemplates\VisualBasic\WPF\3082
Note that one is for vb.Net, there is a CSHARP directory as well.
Edit:
As far as I Know, the templates are for each computer, not for each project, but when you edit the template you can use conditionals, for example:
$if$ ($targetframeworkversion$ >= 3.5)using System.Linq;
You can use the $rootnamespace$ constant to check for a specific project and then add the namespace or not. Maybe a constant with the current project name exists, i don't know, but $rootnamespace$ should be enought for this pourpose.
If it's your own the sourcecode to the assembly you using in the Engine namespace you can accually totaly remove the prefix requerment and the demand of adding something. With this little trick you just append your own namespaces to the xaml namespace (that allready is included).
In your "Engine" project (not the project where you have the xmlns:Engine line, can't be the same project where you use it, it will not work then) make sure you have the WindowsBase reference added and then add the following in the the AssemblyInfo.cs/AssemblyInfo.vb file (c#: found in the Properties folder) (vb: you need to use the "Show all Files" button and then you will find it in the My Project folder):
c#:
[assembly: XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation", "The.Class.Namespace")]
vb:
<Assembly: XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation", "The.Class.Namespace")>
You can do this several times if you project have classes in more then one namespace you wanna use in the other projects xaml.
No, there is no way to avoid this. However declaring a namespace does not mean that it consumes resources (at runtime).

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.

Converting WPF project to Silverlight? System.Windows.UIElement reference cant be found

Im trying to convert my WPF project, written in MVVM template into a silverlight project.
However, i am running into some problems.
There is a class in the ViewModel folder (WPF) called BaseViewModel, that uses System.Windows.UIElement and System.Windows.Application.
But I can not find reference to these classes. Is there a workaround?
Both of these classes are in Silverlight's System.Windows namespace and are supported in SL 3 and 4.
Try installing the Silverlight 4 Tools for Visual Studio from here. When creating a new Silverlight project in VS2010, the reference should be added automatically. For reference, my path to the reference was:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0\System.Windows.dll

Recover WinForms from dll

We think most of the source has been recovered through .NET Reflector. A utility which export the dll as C# source.
The only missing part is WinForms which is not included when .NET Reflector export the dll source.
Is there any way to get the WinForms recover from dll?
Thanks.
If it's not in the dll, you can't get it out :-)
But possible some class files are the forms you're searching for. Maybe you have to add a reference to System.Windows.Forms.dll to your project.
From Visual Studio 2005 on, Windows Forms classes are partial classes split into a Designer generated part (MyForm.designer.cs) and your actual implementation (MyForm.cs). You can see that in Explorer when you create a new Form from scratch.
In order to resolve your problem you would have to split up the class exported by Reflector the same way that Visual Studio does: Place the InitializeComponent() method and all control declarations into the MyForm.designer.cs file and the remaining code into the MyForm.cs file.

Resources