简体   繁体   中英

the type from assembly is built with an older version of blend sdk and is not supported in a windows presentation foundation 4 project

I created a WPF project in VS 2013. After upgrading to VS 2015, this error showed in the designer on types derived from the Blend SDK:

the type from assembly is built with an older version of blend sdk and is not supported in a windows presentation foundation 4 project

  1. Run Command Prompt as Administrator

  2. Change Directory to Blend SDK: cd C:\\Program Files (x86)\\Microsoft SDKs\\Expression\\Blend\\.NETFramework\\v4.5\\Libraries\\

  3. Register DLL: gacutil -i System.Windows.Interactivity.dll

  4. Restart Visual Studio

Reference: https://connect.microsoft.com/VisualStudio/feedback/details/755407/xaml-designer-will-not-display-when-using-blend-sdk-behaviors

You can resolve this issue by manually changing the version numbers in .sln and .csproj files.

In .csproj and .csproj.user change ToolsVersion to your current Visual Studio version. VS 2013 is version 12, VS 2015 is version 14.

In .sln change VisualStudioVersion to the current version, you can find it in the About window.

Also change Microsoft Visual Studio Solution File, Format Version to your current version (eg 14.00, 12.00)

Note: This only works for built-in assemblies. If external dependencies (like Prism) cause this error, you'd have to recompile them using the new Blend SDK. You could also try to update the dependency, maybe the newest version is already compiled using the latest Blend SDK.

None of the other answers here worked for me. What finally solved it was deleting the .NET v4.0 version of the file in the SDK folder:

C:\Program Files (x86)\Microsoft SDKs\Expression\Blend\.NETFramework\v4.0\Libraries\

I am referencing the v4.5 file via NuGet, but it seems that the designer was finding the file in the above folder. The v4.0 file was not registered in the GAC.

Was having a similar problem using Visual Studio 2017 but none of the answers above fully resolved it for me. Found a Microsoft developer community page that had a workaround that did the trick. Comment by Bran Hagger recommended deleting the .vs folder from the solution's directory. This additional step cleared out the cache and caused Visual Studio to rebuild it.

只是Microsoft Visual Studio解决方案文件,格式版本更改为14.00对我有用。

This also could be that you are mixing different versions of System.Windows.Interactivity.dll , especially if you are getting the SDK from nuget where several different packages provide it, eg:

https://www.nuget.org/packages/Expression.Blend.Sdk/ https://www.nuget.org/packages/System.Windows.Interactivity.WPF/

In this case, you'll have to synchronize these libraries among projects.

The popular answer is valid, but since things are always changing in the developer world, I thought I would note that there's a (IMO) better solution now.

In December 2018, Microsoft released an official, open source, supported NuGet package for XAML behaviors for WPF. (There's a separate one for UWP.) It's very easy to migrate to this package. You need to uninstall your current NuGet package, remove a couple of references, install this package, and change a using statement (or FQN).

https://www.nuget.org/packages/Microsoft.Xaml.Behaviors.Wpf/

https://devblogs.microsoft.com/dotnet/open-sourcing-xaml-behaviors-for-wpf/

I read about it in this SO answer, so credit goes to that OP:

How to add System.Windows.Interactivity to project?

Deleting the .vs file in the solution folder solved the issue. The issue happened for me after I updated My Visual Studio 2017 and Opened the project that was built before with an older version of Visual studio 2017.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM