I am working on porting our V10 map project to V12.
am using .Net Framework 4.7.1, not Core.
It seems to be working if compiled as x64, but I get an image format exception when loading the WPF map in 32 bit.
Is 64 bit the only supported version? Or is there something else I should change.
ThinkGeo V12 and 32 bit
Thanks Chris,
Could you paste the detail exception here. We do know one gdal X86 support issue. Not sure it is the one you mentioned.
Thanks
Frank
This occurs during the call to InitializeComponent() in my MainWindow.xaml.cs.
Works fine if I use x64.
This is the line of XAML it is pointing to:
<wpf:MapView Name=“OnyxMap” x:FieldModifier=“public” MapClick=“OnyxMap_MouseClick” KeyDown=“OnyxMap_KeyDown” Focusable=“False” Cursor="{Binding Cursor}" Grid.Row=“1”
Grid.Column=“0”>
System.Windows.Markup.XamlParseException: ‘‘The invocation of the constructor on type ‘ThinkGeo.UI.Wpf.MapView’ that matches the specified binding constraints threw an exception.’ Line number ‘52’ and line position ‘10’.’
BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
The exception "System.Windows.Markup.XamlParseException: ‘‘The invocation of the constructor on type ‘ThinkGeo.UI.Wpf.MapView’ that matches the specified binding constraints threw an exception.’ doesn’t show the real reason underneath the hood, can you check check inner exception in the exception detail and find out the real reason?
There’s a known issue that GDAL doesn’t work properly on X86 mode, I think that might be the cause of your issue. We are working on it right now. I think there should be a fix within a week.
Ben
Ok here is the exception you were looking for I believe (looks like a SkiaSharp exception):
An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
“The type initializer for ‘SkiaSharp.SKAbstractManagedStream’ threw an exception.”
" at SkiaSharp.SkiaApi.sk_managedstream_set_procs(SKManagedStreamDelegates procs)\r\n at SkiaSharp.SKAbstractManagedStream…cctor()"
Skia is supported in both X64 and X86. Please make sure additional to SkiaSharp.dll, you also have libSkiaSharp.dll in the bin folder. The trick part is that there are an X86 and an X64 version of it and you should put the right file there. Those 2 files can be found in bin\x86 and bin\x64 folders independently.
That’s not an issue in a .NET Core project by the way, where libSkiaSharp.dll can be referenced properly in their subfolder. Visual Studio is supposed to copy the right dependency to the bin folder for a .NET Framework project but seems it messes things up every now and then.
Ben
Ben,
The Skia Sharp was the issue I was getting, I got that figured out.
Now I am seeing the GDAL issue when I create UnmanagedProjectionConverter.
We’re working on the GDAL X86 support right now. We’ve have the X86 dependencies ready but now the issue is there’s not a straightforward way to make it easy to work for AnyCPU (dynamically switch over the dependencies for X86 and X64). We are working on it now.
We can send you the X86 GDAL dependencies If what you need is just X86 support, you need to wait a bit longer for AnyCPU support.
I can work with X86 for now. Then update to AnyCPU when ready.
Chris,
Sure here it is.
https://files.thinkgeo.com:5001/sharing/F0Qt6D1sW
Unzip it and you can find X86 Gdal dependencies, a sample project and an executable folder. Open the X86 sample project, compile it and copy all the files in Win32Gdal folder to the bin folder, and your project is ready to go. In case you have any issue setting up the project, I also included the executable files which you can run and tell what the dependencies are.
Here is my test code. A projected world image (projected to Spherical Mercator) will show up after running the test sample.
UnmanagedGeoTiffRasterLayer geoTiffRasterLayer = new UnmanagedGeoTiffRasterLayer(@"C:\Users\BenBai\Documents\ThinkGeoSDKs\ThinkGeo.UI\SampleData\GeoTiff\World.tif");
geoTiffRasterLayer.ImageSource.ProjectionConverter = new UnmanagedProjectionConverter(4326, 3857);
geoTiffRasterLayer.Open();
GeoCanvas canvas = GeoCanvas.CreateDefaultGeoCanvas();
GeoImage geoImage = new GeoImage(800, 600);
canvas.BeginDrawing(geoImage, new RectangleShape(-20000000, 20000000, 20000000, -20000000), GeographyUnit.Meter);
geoTiffRasterLayer.Draw(canvas, new System.Collections.ObjectModel.Collection<SimpleCandidate>());
canvas.EndDrawing();
geoImage.Save("result.png");
Process.Start("result.png");
Thanks,
Ben