3

在 Windows 10 上,我正在开发一个通用应用程序。我有一个项目的目标是从 build 10240 到周年纪念版(14393)。我正在使用 nuget Win2d.uwp,在调试和发布应用程序的同时一切正常。我可以生成一个 Store 包,通过 HockeyApp 部署它,它工作得很好。当我将它上传到商店,并等到它被批准后,下载它并开始使用它,只要我使用 Win2d.uwp 和这段代码在一些控件中绘制阴影:

 public static void InitializeDropShadow(UIElement shadowHost, UIElement shadowTarget, Color color, ShadowPosition position)
    {
        var offset = GetOffset(position);

        var hostVisual = ElementCompositionPreview.GetElementVisual(shadowHost);
        var compositor = hostVisual.Compositor;

        // Create a drop shadow
        var dropShadow = compositor.CreateDropShadow();
        dropShadow.Color = Color.FromArgb(color.A, color.B, color.G, color.R);
        dropShadow.BlurRadius = 25.0f;
        dropShadow.Offset = offset;
        // Associate the shape of the shadow with the shape of the target element
        // dropShadow.Mask = shadowTarget.GetAlphaMask();

        // Create a Visual to hold the shadow
        var shadowVisual = compositor.CreateSpriteVisual();
        shadowVisual.Shadow = dropShadow;

        // Add the shadow as a child of the host in the visual tree
        ElementCompositionPreview.SetElementChildVisual(shadowHost, shadowVisual);

        // Make sure size of shadow host and shadow visual always stay in sync
        var bindSizeAnimation = compositor.CreateExpressionAnimation("hostVisual.Size");
        bindSizeAnimation.SetReferenceParameter("hostVisual", hostVisual);

        shadowVisual.StartAnimation("Size", bindSizeAnimation);
    }

    private static Vector3 GetOffset(ShadowPosition position)
    {
        var result = new Vector3();
        switch (position)
        {
            case ShadowPosition.Center:
                result = new Vector3(0, 0, 0);
                break;
            case ShadowPosition.Top:
                result = new Vector3(0, -SHADOW_OFFSET, 0);
                break;
            case ShadowPosition.Left:
                result = new Vector3(-SHADOW_OFFSET, 0, 0);
                break;
            case ShadowPosition.Right:
                result = new Vector3(SHADOW_OFFSET, 0, 0);
                break;
            case ShadowPosition.Bottom:
                result = new Vector3(0, SHADOW_OFFSET, 0);
                break;
            case ShadowPosition.TopLeft:
                result = new Vector3(-SHADOW_OFFSET, -SHADOW_OFFSET, 0);
                break;
            case ShadowPosition.BottomRight:
                result = new Vector3(SHADOW_OFFSET, SHADOW_OFFSET, 0);
                break;
            default:
                result = new Vector3(0, 0, 0);
                break;

        }
        return result;
    }

它惨遭破坏并抛出这个异常破坏整个应用程序:

System.MissingMethodException: Method not found: 'Void Windows.UI.Composition.DropShadow.put_Offset(System.Numerics.Vector3)'.

它只发生在 STORE 版本中,我没有用 .Net Native 编译它。有任何想法吗?

4

0 回答 0