reference project issue when convert VS2008 to VS2010 - wpf

I have a shared project (C#) used by several other projects.
In VS2008, everything compiles fine. Now I convert all to VS2010, then two referencing projects complain that the shared dll not found
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sharedC="clr-namespace:Shared.Converter;assembly=Shared"
<Window.Resources>
<ResourceDictionary>
<sharedC:BooleanToHiddenVisibility x:Key="boolToVis"/>
...
VS2010 compiler complaint about sharedC: BooleanToHiddenVisibilty not found
the error msg is:
The tag 'BooleanToHiddenVisibility' does not exist in XML namespace 'clr-namespace:Shared.Convert; assembly=Shared'. Line 14 position 14
I compiled shared.dll first and compilation is successful.
I removed shared project from reference and add it back. Still the same error
I checked the path of referenced shared.dll, it is correct
Not sure what I missed.

Found it. After conversion, project used to target .NET framework 3.5, after conversion, it is changed to target .NET framework 3.5 client profile. I change it back to .NET 3.5 framework and it compiles successfully

Related

Where do I find Galasoft.MvvmLight.WPF45 assembly?

I'm using VS2013 Express. I'm quite new in WPF and MVVM. I've downloaded mvvmlight using NuGet to my project. I'm tryinng to use GalaSoft_MvvmLight_Command:EventToCommand. As far as I know, I have to add reference in xaml by adding namespace:
xmlns:GalaSoft_MvvmLight_Command="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight"
But, unfortunatelly I get error, that says:
The tag 'EventToCommand' does not exist in XML namespace
'clr-namespace:GalaSoft.MvvmLight;assembly=GalaSoft.MvvmLight'.
I've found some information, that I have to include GalaSoft.MvvmLight.WPF45 assembly, but I don't see this dll in packages\MvvmLightLibs.5.0.0.1\lib\ folder. There are many folders, for each .NET version etc, but each of these assemblies names are the same, without WPF45 sufix.What is going on? Where do I find this GalaSoft.MvvmLight.WPF45.dll assembly? Or maybe in version 5 was some changes made in names?
Edit:
Using object browser I found that EventToCommand is in GalaSoft.MvvmLight.Platform assembly in GalaSoft.MvvmLight.Command namespace. So I did
xmlns:GalaSoft_MvvmLight_Command="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Platform"
I can compile project now, but I still get errors in xaml (what is weird):
A value of type 'EventToCommand' cannot be added to a collection or dictionary of type 'TriggerActionCollection'
and
The type 'EventToCommand' from assembly 'GalaSoft.MvvmLight.Platform' is built with an older version of the Blend SDK, and is not supported in a Windows Presentation Framework 4 project.
and xaml editor can't display window properly (invalid markup).
Edit2:
Solution for invalid markup.
After I've changed the namespace to xmlns:cmd="http://www.galasoft.ch/mvvmlight" I also change project's target framework from 4.5 to 3.5. IDE shows an error about there are few NuGet packages that target other framework, so I returned to 4.5 - and it magically works now ;). Thanks all for help.
Here's how its done now in your XAML assuming you've got Version 4.0.0. Beat 1 or higher:
xmlns:cmd="http://www.galasoft.ch/mvvmlight"
I found this at the bottom the release notes here: http://www.mvvmlight.net/installing/changes/
Details
XmlnsDefinitionAttribute for GalaSoft.MvvmLight.Command in Extras assembly
Thanks to the addition of XmlnsDefinitionAttribute, you can simplify the inclusion of the MVVM Light EventToCommand action in XAML. See the before and after below:
Before:
<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.SL4"
xmlns:cmd="http://www.galasoft.ch/mvvmlight"
x:Class="MvvmLight4.MainPage">
After:
<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:cmd="http://www.galasoft.ch/mvvmlight"
x:Class="MvvmLight4.MainPage">
EventToCommand exists in the Extras assembly.
Try:
xmlns:GalaSoft_MvvmLight_Command="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras"
More Information:
To determine the assembly a class falls in, I usually Go To Definition and the assembly is referenced in the region at the top of the [from metadata] code file.

wpftoolkit chartin, namespace referencing in XAML

I am using the basic WPFToolkit - I have both DLL's embedded in my EXE. I followed this tutorial:http://www.digitallycreated.net/Blog/61/combining-multiple-assemblies-into-a-single-exe-for-a-wpf-application
Everything is working with the DLL not embedded. When embedded, while I can compile with no error, I get a parsing error pointing at the XAML referencing of the wpftoolkit dll.
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:chartingToolkit="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit" x:Class="Swiftech_Imperium.MainWindow"
both DLL's are set to embedded resources, and both references are set to do not copy.
If I enable copy local for the system.windows.controls.datavisualization.toolkit.dll it works, but then I need the DLL at the root of the exe (I shouldn't need that since it's already embedded in the EXE - and I can't do this for this specific project..)
any idea what's wrong here?
thanks
Just because the .DLL reference is set to Embedded Resource doesn't mean the libraries will get resolved/loaded at runtime. You need to manually do that. I'm not sure if WPFToolKit can successfully do that, but to test it, you will want to to follow the answer found here.

Wpf Assembly Reference failing for Mef powered application that has executing assembly and mef modules physically separated

We have an application as well as a Visual Studio add-in that both load their (modular) functionality from Mef assemblies located elsewhere on a users machine than the application is installed itself.
Now one of our developers used Wpf (using Prism/System.Windows.Interactivity) to create the UI component for a new module but unfortunately now the module / Xaml Parser throws a XamlParseException saying that it cannot load System.Windows.Interactivity.dll and looking at the fusion log basically shows that the paths its looking for / in is the one the hosting .exe runs from, not where the Mef module (containing the wpf / xaml ui) resides in.
The System.Windows.Interactivity.dll does in fact reside in the Mef's module/assembly directory (referenced in that mef module / assembly and copy local set to true) so I was wondering how we would specify the namespace for System.Windows.Interactivity properly below so the assembly loading does in fact look in the assembly's directory aswell?
<UserControl x:Class="TestExplorer.Modules.DocumentChecks.DocumentChecksMainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:Command="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WPF4"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:Converter="clr-namespace:TestExplorer.Modules.DocumentChecks.Converter"
xmlns:TreeView="clr-namespace:TestExplorer.Modules.DocumentChecks.TreeView" mc:Ignorable="d"
d:DesignHeight="500" d:DesignWidth="500">
There is one entry here at SO that has the exact same problem (see Prism assembly reference failure: System.Windows.Interactivity), however the solution to add prism/system.windows.interactivity as reference to the hosting application is only a workaround, at best - it basically defeats the applications' modular purpose (leave alone that we cannot deploy the system.windows.interactivity into the devenv.exe's location in case users use our Visual Studio Addin.. and devenv.exe being the hosting process there).

Can't find type 'ResourceDictionary'?

I have the following XAML as a resource dictionary but Visual Studio 2008 is telling me that it can't find the ResourceDictionary tag.
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Views="clr-namespace:Locate.Client.Views"
xmlns:Presentation="clr-namespace:Locate.Client.Presentation;assembly=Locate.Client.Presentation">
The specific error message is Error 1 The type 'ResourceDictionary' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built. C:\dev\Locate\src\Locate.Client\Views\..\Resources\MainWindowResourceDictionary.xaml 1 2 Miscellaneous Files
.
Any reason why it can't find this tag?
looks ok to me.
Vs2008 is buggy when it comes to using with XAML. try to upgrade to 2010 if you can. if you still using VS, make sure you got latest SP
otherwise, try to reopen, had similar issue in the past, restart fixed it miraculously :) upgraded to VS2010 at the end

Can't use WPF designer because can't find custom base window type in XAML, but code behind is fine

I am using a base Window class in a WPF project. In the code behind C# file the assembly to the base type is referenced and fine. In the XAML is looks like this:
<MyNamespace:WindowBase x:Class="MyNamespace.Applications.UserInterface.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:MyNamespace="clr-namespace:MyNamespace.Somewhere;assembly=MyNamespace.Common"
Title="MainWindow" Height="350" Width="525">
<Grid>
</Grid>
The solution compiles fine and I can run it. I just can't use the designer in VS 2010. It throws the following exception: The type'MyNameSpace:WindowBase' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.
Well. they have been. I can't understand what this issue is. This particular base class is used in other projects just fine. I grabbed it for a new project and I can't use the designer. Very frustrating.
Found this problem just recently (this answer upgraded from a comment).
If you copy the dll from a network path, you must right click on the file in Windows Explorer, select Properties, then 'unblock'; there is a hidden NTFS stream associated with the file, and many files when you download from the 'net or copy from a network path, for security reasons.
Only the designer complains, yet the project builds and runs fine: weird isn't it?!
Whenever the designer is acting up against me - the first thing I do is clear the obj-folders in the project and rebuild. Sometimes they seem to go out of sync for some reason (usually when I'm drag-dropping a lot of files and renaming visual items).
I dont't know if its the same issue but in VS2008 I tried to make abstract UserControls but had to change this because the designer didnt't support any abstract base classes (however the solution was compilable and also worked as excpected).
Fixed. The library that contained my base class resided on a drive on the network that I did not have permissions to. That seemed to have no affect on VS 2008 as it worked, but VS 2010 apparently took exception to that when the designer tried to load it. Weird.

Resources