Compatibility issue with Expression.Blend.Sdk 1.0.

2019-07-18 19:58发布

问题:

I'm developing a WPF with Visual Studio 2015 Community, C#, .NET Framework 4.6.1 and Prism.Wpf 6.1.0, Prism.Core 6.1.0 and Expression.Blend.Sdk 1.0.2.

I'm following: Implement a confirmation dialog in WPF using MVVM and Prism tutorial.

I have added Interaction triggers to a Windows.xaml:

<Window x:Class="MyProject.Views.MainWindow"
        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:MyProject.Helpers"
        xmlns:ViewModel="clr-namespace:MyProject.ViewModels"
        xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
        mc:Ignorable="d"
        Title="MainWindow" Height="604.62" Width="655.879">
    <Window.DataContext>
        <ViewModel:MainViewModel/>
    </Window.DataContext>
    <i:Interaction.Triggers>
        <!-- Trigger listening for the "Raised" event on the source object (of type IInteractionRequest) -->
        <i:EventTrigger EventName="Raised" SourceObject="{Binding ConfirmationInteractionRequest}">
            <i:EventTrigger.Actions>
                <local:StartBatchWindowAction />
            </i:EventTrigger.Actions>
        </i:EventTrigger>
    </i:Interaction.Triggers>
    <Grid x:Name="MainGrid">

I get the following error on <local:StartBatchWindowAction />:

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

This is StartBatchWindowAction class:

using System;
using System.Windows;
using System.Windows.Interactivity;

namespace TRZ_Domino.Helpers
{
    public class StartBatchWindowAction : TriggerAction<FrameworkElement>
    {
        protected override void Invoke(object parameter)
        {
            throw new NotImplementedException();
        }
    }
}

I have done all the steps in this SO answer but when I tried to compile PrismLibrary_Wpf and get another error:

IServiceLocator not found.

How can I fix this problem?

I have used ILSpy to check that dll and this is what I got:

// D:\Development\packages\Expression.Blend.Sdk.1.0.2\lib\net45\System.Windows.Interactivity.dll
// System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35

// Global type:
// Architecture: AnyCPU (64-bit preferred)
// Runtime: .NET 4.0

using System;
using System.Diagnostics;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Windows.Markup;

[assembly: AssemblyVersion("4.5.0.0")]
[assembly: CLSCompliant(true)]
[assembly: Debuggable]
[assembly: AssemblyCompany("Microsoft Corporation")]
[assembly: AssemblyCopyright("Copyright (c) Microsoft Corporation. All rights reserved.")]
[assembly: AssemblyDescription("System.Windows.Interactivity")]
[assembly: AssemblyFileVersion("3.0.40218.0")]
[assembly: AssemblyProduct("System.Windows.Interactivity")]
[assembly: AssemblyTitle("System.Windows.Interactivity")]
[assembly: NeutralResourcesLanguage]
[assembly: CompilationRelaxations(8)]
[assembly: InternalsVisibleTo("Microsoft.Expression.DesignSurface.UnitTests, PublicKey=...")]
[assembly: InternalsVisibleTo("Microsoft.Expression.BlendSDK.UnitTests, PublicKey=...")]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: ComVisible(false)]
[assembly: TargetFramework(".NETFramework,Version=v4.5", FrameworkDisplayName = "")]
[assembly: XmlnsDefinition("http://schemas.microsoft.com/expression/2010/interactivity", "System.Windows.Interactivity")]
[assembly: XmlnsPrefix("http://schemas.microsoft.com/expression/2010/interactivity", "i")]
[assembly: SecurityPermission(8, SkipVerification = true)]
[module: UnverifiableCode]

I have removed Prism from the project and I get the same error, so this is not a problem with Prism.

Github source code.