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
Related
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.
I have a merged resource dictionary in App.xaml Main assembly, which combines various resource dictionaries from separate assemblies: Common and PresentationLayer.
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Common;component/Themes/Button.xaml"/>
<ResourceDictionary Source="/PresentationLayer;component/DataTemplates/AppointmentsDataTemplates.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
At run time the styles in the resource dictionaries are applied to the controls correctly. However, at design time the styles are not applied and Visual Studio 2012 keeps giving the following error:
An error occurred while finding the resource dictionary "/Common;component/Themes/Button.xaml".
And warning:
The resource "BannerButton" could not be resolved.
I came across this post but the problem persists despite Build Action set to Resource. Also, I did not have this problem when running under Visual Studio 2010 or Expression Blend 4. The Main assembly definitely holds a reference to the Common assembly and I haven't changed the Pack URIs.
For VS2017 if assembly is referenced and double-checked that all namings are OK try to close VS and delete .vs directory in solution directory. This will cause you to lose all user settings (startup project, WPF designer zoom, etc.) but will fix this.
This was a known issue with Visual Studio 2012. See this link at Microsoft Connect. After installing VS2012 Update 1 this issue resolved for me. If you think you're running the most up to date version of VS2012 and still experiencing this issue, make absolutely sure that the update has been applied. I thought I had updated using Windows Update, but then found that I had to tell VS2012 to apply the update. After VS2012 did its thing everything was fine.
If you are using Visual Studio 2017, try to restart your computer. The problem may be solved.
I'm using VS2019 getting this error.
I just restart the VS and the error disappeared.
Try the same in Window.Resources, make sure you added namespace when using app.xaml and don't forget to change the build option to page where you need to use that app.xaml.
I had the same Issue and the cause was wrong spelled word in the resource dictionary xaml file. Check the resource dictionary xaml file for wrong spellings and errors. After correcting the spelling it worked.
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
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.
for some reason, my visual studio 2010 is not loading debug symbols on my own code.
i am using a default WPF application solution. with a sample WPF app i am working on, and running in Debug mode.
when i go into debug, i can step through my code.
BUT
when exception happens in my code (i.e. throw new Exception("test")), visual studio gives me the blue blank screen with "No Source Available. No symbols are loaded blah blah.."
AND
i can actually "view" exception details, where it will tell me the line of code my exception occured on.
so it does know what happened.. it seems.
it seems to think that PDB files are not loaded.
my setup:
options > Deubg > "Enable just my code (managed only)" is checked.
application properties : 1 project running in Debug x86
Loading symbols should be configured on : Tools -> Options -> Debugging -> Symbols where you can choose to Automatically load symbols for: "All modules" or "Only specified modules". This should be set to all modules. If you get "no source available" for exceptions in the .NET framework like I did you should hit the "empty symbol cache" button. This worked for me.
I was also facing this issue and luckily find out following solution.
If you do not want to debug .NET assembly, a quick fix to avoid "No source available to current location" problem is to uncheck "Require source files to exactly match the original version" check-box under Tool -> Options -> Debugging -> General
Please let me know, if it solves your problem.
Thanks
Shilpa
Tried Debugging answer and didn't have any luck. What I think happened, in my case...
I renamed some files/namespaces/etc during a cleanup and my App.xaml was pointing to a now non-existant namespace.
This is what I had in my code:
<Application x:Class="Patcom.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="SomethingElse.xaml"
xmlns:p="clr-namespace:Patcom.Properties">
....
</Application>
This is what I needed in my code (Notice the changed StartupUri in my case):
<Application x:Class="Patcom.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="Patcom.xaml"
xmlns:p="clr-namespace:Patcom.Properties" >
....
</Application>
No clue if this is remotely your case. I'm still very noobish and there isn't a whole lotta information in your post... but i found this while searching for the same problem on my code.
Further Notes:
After more research... I found another post claiming that the problem really lies with date-stamps on objects in the Bin & Obj directories becoming out of sync between multiple "projects" in the same solution.
I don't have the link anymore, but what I've ended up doing is deleting Bin & Obj directories. We'll see shortly if I have the same problems on my work computer that I had on my home computer.
This worked for me:
Just reset your objects
Like you are using dataset ds=new dataset();
A common dataset for many results or tables then reset it using ds.reset();
Before using the dataset again.