Search code examples
sql-serverazureasp.net-corenettopologysuite

Error after deploy to Azure: "The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect."


I'm developing app in .NET Core 3.1 with Visual Studio 2019 and everything works fine on my local machine with Windows 10 Pro. But after deploy to Azure this problem occurs:

The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Parameter 9 ("@p8"): The supplied value is not a valid instance of data type geography. Check the source data for invalid values. An example of an invalid value is data of numeric type with scale greater than precision

This error occurs when adding Post to database. Post has property of type NetTopologySuite.Geometries.Point and is set like that: location = new Point(longitude, latitude) { SRID = 4326 }; where longitude and latitude are double.

When I set location to null then error doesn't appear. I tried to use less precision, like 2 digits before dot and 6 digits after - this still causes error.

I use Entity Framework Core. It generated db column as Location (geography, null).

Edit: I'm converting lat and lon strings to double like that: Convert.ToDouble(longitude.Replace(".", ",")). I removed .Replace(".", ",") and now it works on Azure, but the same error appear on local env. I have spatial with id 4326 on both dbs.


Solution

  • Finally i changed:

    Convert.ToDouble(longitude.Replace(".", ","))

    to

    Convert.ToDouble(longitude, CultureInfo.InvariantCulture)

    and now it works on both - local and Azure.

    Solution inspired by this: string to double issue, dot is removed