.netwpf64-bitpixelsensescatterview

ScatterView runtime exception on x64


I have the same issue as described here.

We have developed several applications using the old Microsoft Surface 2.0 SDK. The applications are built as AnyCPU and those work perfectly fine running both in 32 bit and 64 bit mode. In one of these application I use a ScatterView.

<Window x:Class="WpfApplication1.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:s="http://schemas.microsoft.com/surface/2008"
    Title="MainWindow" Height="350" Width="525">
    <Grid>
        <s:ScatterView x:Name="timeline">
            <Rectangle></Rectangle>
        </s:ScatterView>
    </Grid>
</Window>

However if I try to add a new ScatterView in a new blank Window I get this error:

{"The type initializer for 'Microsoft.Surface.Core.InteractiveSurface' threw an exception."}

System.TypeInitializationException was unhandled
HResult=-2146233036
Message=The type initializer for 'Microsoft.Surface.Presentation.Input.InteractiveSurface'  threw an exception.
Source=Microsoft.Surface.Presentation
TypeName=Microsoft.Surface.Presentation.Input.InteractiveSurface

If I force the application to run in 32 bit it runs perfectly. However the application is pretty memory intensive so I would like to run it in 64 bit as well.

My question is: How come the ScatterView in my current application runs perfectly in 64 bit, but adding an additional ScatterView to this application or creating a brend new application crashes immediately. Unfortunately the answer given in the previous questions has a dead link.


Solution

  • Of course after 48 hours of searching I found a solution to my own question.

    When you add an item in the ScatterView, a call is made to the function GetItemOrientation in Microsoft.Surface.Presentation.Controls.ScatterCanvas. This function determines the rotation of the ScatterViewItem. When running your application in 64bit this method fails and throws an exception, probably caused by a call to a native method to determine the orientation of the SUR40 on which it is supposed to run.

    Solution: You can disable the function call to GetItemOrientation by setting the Orientation property on the ScatterViewItem yourself or by setting ScatterViewItem.CanRotate = false.