ThinkGeo.com    |     Documentation    |     Premium Support

Exception when GeometryValidationMode set to SqlGeometry

Recently I tried setting the GeometryValidationMode on a shapefile to SqlGeometry. When I run the application from the IDE or anywhere else on my developer machine, there is no problem. But when I deploy to my test user machine an exception is generated on this line of code:

Dim oFeatures = moPointsLayer.QueryTools.GetFeaturesIntersecting(moSelectPolygon, ReturningColumnsType.NoColumns)

For my testing I simply copied the entire Release or Debug folder to the machine. All dependencies that should be on the target machine are there, and this exception always happens:

Exception Source: ThinkGeo.MapSuite
Exception Type: System.InvalidOperationException
Exception Message: Looks up a localized string similar to To use this method, you have to reference Microsoft.SqlServer.Types.dll, and copy folder[Install-Path]\Developer Reference\[Product]\SqlServerTypes_X64(SqlServerTypes_X86) to System32\Map Suite *.* folder for x86/x64 platform.
Exception Target Site: MakeValid



---- Stack Trace ----
rSY=.tCY=.MakeValid(feature As Feature)
GeoSuite.exe: N 00265
System.Linq.WhereSelectEnumerableIterator`2.MoveNext()
GeoSuite.exe: N 00235
System.Collections.Generic.List`1..ctor(collection As IEnumerable`1)
GeoSuite.exe: N 00453
System.Linq.Enumerable.ToList(source As IEnumerable`1)
GeoSuite.exe: N 00073
ThinkGeo.MapSuite.Layers.FeatureSource.6Cc=(features As Collection`1)
GeoSuite.exe: N 00138
ThinkGeo.MapSuite.Layers.FeatureSource.SpatialQuery(targetShape As BaseShape, queryType As QueryType, returningColumnNames As IEnumerable`1)
GeoSuite.exe: N 01373
MapUtilities.frmGridAnalysis.mGenerateGrid(eGeographyUnit As GeographyUnit)
frmGridAnalysis.vb: line 0349, col 05, IL 0634
MapUtilities.frmGridAnalysis.btnCreateGrid_Click(sender As Object, e As EventArgs)
frmGridAnalysis.vb: line 0476, col 05, IL 0174
System.Windows.Forms.Control.OnClick(e As EventArgs)
GeoSuite.exe: N 00135
Infragistics.Win.Misc.UltraButtonBase.OnClick(e As EventArgs)
GeoSuite.exe: N 00137
Infragistics.Win.Misc.UltraButton.OnMouseUp(e As MouseEventArgs)
GeoSuite.exe: N 00205
System.Windows.Forms.Control.WmMouseUp(m As Message&, button As MouseButtons, clicks As Int32)
GeoSuite.exe: N 00733
System.Windows.Forms.Control.WndProc(m As Message&)
GeoSuite.exe: N 02428
System.Windows.Forms.NativeWindow.Callback(hWnd As IntPtr, msg As Int32, wparam As IntPtr, lparam As IntPtr)
GeoSuite.exe: N 00194

I have attached a small sample project that will reproduce the issue. Again, note, you will not receive the exception if you run on a development machine.

Thanks!

Steve

SqlServerTypesException.zip (248.0 KB)

Hey @Steven1,

On your deployed machine, have you taken the SqlServerTypes_X64/X86 folder and transferred it to the System32\Map Suite folder like the error message mentions? You may also need to install the SQLSysCLRTypes package on the target machine as well.

Thanks,
Kyle

Hi Kyle,

We have been using the Microsoft.SqlServer.Types library directly from our code for years and we have never had to install anything to System32\Map Suite. We deploy Microsoft.SqlServer.Types.dll to the application folder and the correct version of SqlServerSpatial(110-150).dll in System32. We are targeting 64 bit machines only. The only problem we have ever had was when we tried to use GeometryValidationMode = SqlGeometry. I did try creating a System32\Map Suite folder on the target machine and copied Microsoft.SqlServer.Types.dll into it but it did not solve the problem. Did you try my project on a target machine?

Thanks!

Steve

Hey @Steven1,

I did try it on a target machine, and yes it does occur there. There are specific DLLs that we are looking for in order for us to use SQL Types in C:\Windows\SysWOW64:

SqlServerSpatial140.dll
msvcp120.dll
msvcp120d.dll
msvcr120.dll
msvcr120d.dll

Once I had those DLLs in place, it worked on that target machine. Now, I’m working on getting the debug dlls off that list for the release version. I’ve already tested it locally. It’ll get updated on Nuget via the develop branch first and I’ll make another test run out of it. Once that’s confirmed, I’ll send it to the release list. Then you’ll just need to download the SqlType CLR from SqlServer 2017 and Visuall C++ Redistributable for 2013 on the machine to work.

Thanks,
Kyle

Kyle,

Thanks, that fixes the problem on my deployment machine also. I wasn’t expecting to have to deploy any 32 bit dlls since our application is 64 bit, so I wasn’t looking there.

Thanks!

Steve

Hey @Steven1,

Good to hear that it’s working for you now.

The thing with SQL Types is that it isn’t even really compatible with .NET Core applications. It’s apparently getting a port, but what they have now is not ready and dotMorten’s port is missing a lot of key functionality. You can see the some of the dicussions here:

https://docs.microsoft.com/en-us/answers/questions/638142/future-of-microsoftsqlservertypes-in-net-core-or-n.html

Thanks,
Kyle