In my Windows class library (consumed by the MVC website) I installed NugetPackage Microsoft.SqlServer.Types (Spatial).
Now, using ado.net, I am trying to read the value by doing:
protected SqlGeography MapSqlGeography(DbDataReader reader, string key)
{
return reader[key] is DBNull ? null : (SqlGeography)reader[key];
}
If I add a brake point in this line and in the window of the visual studio window, I type: "reader [key]", I can see the correct point (XXXX, XXX) like: " object {Microsoft.SqlServer.Types.SqlGeography}"
But, as soon as I try to throw, I have the following error:
(SqlGeography)reader[key] The type 'Microsoft.SqlServer.Types.SqlGeography' exists in both
'Microsoft.SqlServer.Types.dll' and
'Microsoft.SqlServer.Types.dll'
The main strange fact is that the dlls are exactly the same ...
As far as I know, I have only one "source" for this namespace / class name, it should not be duplicated ....
"":
using Microsoft.SqlServer.Types;
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Data.SqlClient;
using System.Threading.Tasks;
, ? .
# 1
NugetPackage `Microsoft.SqlServer.Types(Spatial) ' , : "Microsoft.SqlServer.Types(Unofficial)", /, "bin/obj", ....
... .
# 2
extern alias destination;
return reader[key] is DBNull
? null
: (destination.Microsoft.SqlServer.Types.SqlGeography)reader[key];
:
Cannot cast 'reader[key]' (which has an actual type of 'Microsoft.SqlServer.Types.SqlGeography')
to
'Microsoft.SqlServer.Types.SqlGeography'
Microsoft.SqlServer.Types.SqlGeography