I am trying to use Blend 3.0 to edit a project that contains some WPF controls. This project already compiles and runs fine from Visual Studio 2008.
In Blend however, I'm getting mysterious errors that make no sense:
For example, I have a class that derives from Control :
namespace Company.WPFControls.SearchTextBox
{
public class SearchTextBox : Control
{
...
}
}
And I try to use it in a resource, in the same assembly, to assign a style:
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Company.WPFControls.SearchTextBox"
<Style TargetType="{x:Type local:SearchTextBox}">
...
</Style>
</ResourceDictionary>
I get the following error in Blend:
The name "SearchTextBox" does not exist in the namespace "clr-namespace:Company.WPFControls.SearchTextBox".
I've tried specifying the assembly name, by adding ;assembly=Company.WPFControls
but it doesn't remove the error.
Is there any way to fix this or at least figure out where the problem comes from?
I had the same problem with Blend 2, on a Windows Vista 64.
I normally compile my solution in VS2008, with a "Debug - x86" target on all my projects, so that it's compatible with some other 32 bits-only projects.
It looks like Blend loves the "Debug - Any CPU" targets. I basically changed my configuration manager so that it targets Any CPU platforms instead of x86.
So...
I did the opposite to verify if it was really that, and it seems yes... I simply reverted the solution changes back to Debug - x86, cleaned everything, and rebuilded, and I was still back with the error "Does not exist [...]"
As for the "Why?"... I don't know, but at least it works now!
The problem is in Blend assembly search path. By default it search classes in assemblies in folder "bin\Debug"! But if you set in project configuration target x86 then your output path will be "bin\x86\Debug". So you need to change your output path in visual studio to "bin\Debug" and Blend will find all your classes!
I think that Blend uses the default config/platform defined in the project file. You should be able to fix this by editing it with a text file. If you look in your .csproj file, you should see something like this:
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
...
Change that AnyCPU to x86 and it should work the way you expect.
You can also fix this "Any CPU/x86" issue by changing the output path for all your projects to bin\Debug
instead of bin\x86\Debug
(same for Release).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With