简体   繁体   中英

Visual Studio 2010 Designer can't find assembly

I am getting the following error in the VS2010 designer:

System.Reflection.Adds.UnresolvedAssemblyException Type universe cannot resolve assembly: Microsoft.Expression.Interactions, Version=4.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.

It is a Silverlight project and the missing assembly is referenced by the project. The project compiles and runs fine.

I looked with fuslogvw and I can't find that error message.

Do I need to copy the dll somewhere where the Designer can find it?

This assembly is part of Blend SDK. You can install it for free from here: Microsoft Expression Blend Software Development Kit (SDK) for .NET 4 .

If you're using zipped .dll's downloaded from the web under Vista or Win7, the OS blocking feature can cause this problem. I wrote up a blog post last week about how to unblock prior to unzipping a file. I know it solved a very similar problem I was having with Ninject.

I also faced this problem an finally resolved it in an unusual but successful way.

We are using Blend SDK's System.Windows.Interactivity and Microsoft.Expressions.Interactions .

Everything works fine, unless the designer crashes when using an inherited DataTrigger with the same Exception. This would not be the mess, but the exception also breaks IntelliSense in the whole XAML Document, which is not acceptable.

Since this is a reprocducible and reportet error, I decided to solve the problem using disassembling, since we need the extensions to the Interaction Framework.

See: http://connect.microsoft.com/VisualStudio/feedback/details/648819/visual-studio-2010-silverlight-designer-crash

Simply get a Versions of SharpDevelops ILSpy, and open the two assemblies within it. Select the assembly from the list and go to File -> Save. This will disassemble the whole projects. Integrate those in a blank solution and change the assembly names. Rebuild the reference from the Expression.Interactions library to your new disassembled version.

In the AssemblyInfo.cs you can do a trick.

In Microsoft.Expression.Interactions :

[assembly: XmlnsPrefix("http://yourdomain.com/interactions", "i")]
[assembly: XmlnsDefinition("http://yourdomain.com/interactions", "Microsoft.Expression.Interactivity.Core")]
[assembly: XmlnsDefinition("http://yourdomain.com/interactions", "Microsoft.Expression.Interactivity.Input")]
[assembly: XmlnsDefinition("http://yourdomain.com/interactions", "Microsoft.Expression.Interactivity.Layout")]
[assembly: XmlnsDefinition("http://yourdomain.com/interactions", "Microsoft.Expression.Interactivity.Media")]

in System.Windows.Interactivity :

[assembly: XmlnsPrefix("http://yourdomain.com/interactions", "i")]
[assembly: XmlnsDefinition("http://yourdomain.com/interactions", "System.Windows.Interactivity")]

Now put a reference to the new projects in your assembly, or build the assemblies and copy a version of them to your libraries folder and reference the built versions directly.

In XAML add the new namespace to your rootelement like page/window:

<RootElement xmlns:i="http://yourdomain.com/interactions">
    <!-- your xaml code -->
    <i:Interaction.Triggers> ... </i:Interaction.Triggers>
</RootElement>

It works like a charm. You can use both interaction and expressions functionality combined into one xmlns and of course, the designer exception is gone and IntelliSense will no longer break.

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