为什么我得到 FatalExecutionEngineError
why am i getting FatalExecutionEngineError
我正在 运行宁此代码
var existing =( from r in DB.Database.Entities.OfType<DBWorkReport>()
where Math.Round(r.Location.Latitude ?? 0, 6) == Math.Round(latitude, 6)
&& Math.Round(r.Location.Longitude ?? 0, 6) == Math.Round(longitude, 6)
&& r.WorkType.Description == type
select r).FirstOrDefault();
错误也发生在一个简单的
DB.Database.Entities.ToList();
其中
数据库是
public class DatabaseInterface : INotifyPropertyChanged
{
public void Initialise()
{
if (Database == null)
{
Database = new DataDBEntities();
}
}
public event PropertyChangedEventHandler PropertyChanged;
private DataDBEntities _Database;
public static readonly PropertyChangedEventArgs DatabaseProperty = new PropertyChangedEventArgs(nameof(Database));
public DataDBEntities Database
{
get { return _Database; }
set
{
_Database = value;
PropertyChanged?.Invoke(this, DatabaseProperty);
}
}
实体是
public virtual DbSet<DBEntity> Entities { get; set; }
DBWorkReport 是
public partial class DBWorkReport : DBEntity
和r.Location是DBGeography
但是当我 运行 它时,它会抛出
FatalExecutionEngineError occurred HResult=-2146233082
Message=Exception of type 'System.ExecutionEngineException' was
thrown. InnerException:
引用 MSDN:
FatalExecutionEngineError:
This type previously indicated an unspecified fatal error in the
runtime. The runtime no longer raises this exception so this type is
obsolete.
在另一点我成功地调用了这段代码,所以问题似乎不是与 SQLServer 的连接
lookups = DB.Database?.Lookups.Where(l=>l.companyid==DB.CompanyID).ToLookup(g => g.LookupTypeId) ;
那么什么不起作用?
更新:
来自数据库
SELECT *,
[Location].ToString() as WKT
FROM [WorkReport]
Id TypeID ProximityId lineID Location WKT
178 6 2 7 0xE6100000010C8743DC9D754E4A40EB4B08A5400102C0 POINT (-2.25061158114976 52.6129643750674)
179 4 2 7 0xE6100000010CC4A6BF62F7504A40F9ACC89EB70602C0 POINT (-2.25327991533197 52.6325496135519)
180 7 2 7 0xE6100000010CAFC1F420EF624A40D795D41A58F301C0 POINT (-2.24382039033183 52.7729226298428)
181 7 3 7 0xE6100000010C988B36673E654A40E049A63A0BEA01C0 POINT (-2.23927923030827 52.7909668938002)
182 6 2 7 0xE6100000010CF3D11F539F8B4A4028430DF623DE02C0 POINT (-2.35846702793096 53.0907997041103)
183 8 2 8 0xE6100000010C82B9B41004534A40F97B9728ECDEF8BF POINT (-1.55442443710467 52.6485615618176)
184 4 2 6 0xE6100000010C8A8A301567434A409AFAF6A6232BFEBF POINT (-1.88553204746828 52.5265833365457)
185 9 2 4 0xE6100000010CBB7D019FD8404A40BD903C1DCA5902C0 POINT (-2.29384253350335 52.5066107518464)
186 8 2 4 0xE6100000010CF2EDF4D773134A406773A2484D9907C0 POINT (-2.94985443826447 52.1519727655358)
187 6 1 4 0xE6100000010C381064A1F6F849408310A651BCD10CC0 POINT (-3.60240997112311 51.94502656351)
188 2 3 4 0xE6100000010CD3FCB73E6AF3494087D7B17DB7950EC0 POINT (-3.82310388754826 51.9016798399331)
189 2 1 4 0xE6100000010C44BB08BD5EED4940C320C2BF4A9610C0 POINT (-4.14676952001918 51.8544536869654)
190 6 2 4 0xE6100000010C0124660902D8494019DDE9B866BC13C0 POINT (-4.93398560454741 51.6875621556028)
191 1 2 4 0xE6100000010CF135C7CD4DDD494082104C75780714C0 POINT (-5.00729544903527 51.7289368841847)
在调用 Math.Round():
时尝试将纬度和经度转换为 (double)
var existing =( from r in DB.Database.Entities.OfType<DBWorkReport>()
where Math.Round((double)r.Location.Latitude ?? 0, 6) == Math.Round(latitude, 6)
&& Math.Round((double)r.Location.Longitude ?? 0, 6) == Math.Round(longitude, 6)
&& r.WorkType.Description == type
select r).FirstOrDefault();
确保 'longitude' 和 'latitude' 也是 'double' 类型。
visual studio 突出显示的代码实际上与错误无关,它是使用 GDAL 库将北和东参考重新投影到 [= 的代码的较早部分15=],代码本身可以正常工作,但在我删除该代码后,该库的某些内容显然导致了错误,因为它在第二次停止时停止了该代码
using (OSGeo.OSR.SpatialReference inSpatialRef = new OSGeo.OSR.SpatialReference(""))
using (OSGeo.OSR.SpatialReference outSpatialRef = new OSGeo.OSR.SpatialReference(""))
{
inSpatialRef.ImportFromEPSG(form);
outSpatialRef.ImportFromEPSG(to);
using (OSGeo.OSR.CoordinateTransformation coordTransform = new OSGeo.OSR.CoordinateTransformation(inSpatialRef, outSpatialRef))
{
coordTransform.TransformPoint(cord);
}
}
return cord;
这表明问题出在作为 GDAL 包的一部分提供的osr_csharp.dll
我正在 运行宁此代码
var existing =( from r in DB.Database.Entities.OfType<DBWorkReport>()
where Math.Round(r.Location.Latitude ?? 0, 6) == Math.Round(latitude, 6)
&& Math.Round(r.Location.Longitude ?? 0, 6) == Math.Round(longitude, 6)
&& r.WorkType.Description == type
select r).FirstOrDefault();
错误也发生在一个简单的 DB.Database.Entities.ToList();
其中
数据库是
public class DatabaseInterface : INotifyPropertyChanged
{
public void Initialise()
{
if (Database == null)
{
Database = new DataDBEntities();
}
}
public event PropertyChangedEventHandler PropertyChanged;
private DataDBEntities _Database;
public static readonly PropertyChangedEventArgs DatabaseProperty = new PropertyChangedEventArgs(nameof(Database));
public DataDBEntities Database
{
get { return _Database; }
set
{
_Database = value;
PropertyChanged?.Invoke(this, DatabaseProperty);
}
}
实体是
public virtual DbSet<DBEntity> Entities { get; set; }
DBWorkReport 是
public partial class DBWorkReport : DBEntity
和r.Location是DBGeography
但是当我 运行 它时,它会抛出
FatalExecutionEngineError occurred HResult=-2146233082
Message=Exception of type 'System.ExecutionEngineException' was thrown. InnerException:
引用 MSDN:
FatalExecutionEngineError: This type previously indicated an unspecified fatal error in the runtime. The runtime no longer raises this exception so this type is obsolete.
在另一点我成功地调用了这段代码,所以问题似乎不是与 SQLServer 的连接
lookups = DB.Database?.Lookups.Where(l=>l.companyid==DB.CompanyID).ToLookup(g => g.LookupTypeId) ;
那么什么不起作用?
更新:
来自数据库
SELECT *,
[Location].ToString() as WKT
FROM [WorkReport]
Id TypeID ProximityId lineID Location WKT
178 6 2 7 0xE6100000010C8743DC9D754E4A40EB4B08A5400102C0 POINT (-2.25061158114976 52.6129643750674)
179 4 2 7 0xE6100000010CC4A6BF62F7504A40F9ACC89EB70602C0 POINT (-2.25327991533197 52.6325496135519)
180 7 2 7 0xE6100000010CAFC1F420EF624A40D795D41A58F301C0 POINT (-2.24382039033183 52.7729226298428)
181 7 3 7 0xE6100000010C988B36673E654A40E049A63A0BEA01C0 POINT (-2.23927923030827 52.7909668938002)
182 6 2 7 0xE6100000010CF3D11F539F8B4A4028430DF623DE02C0 POINT (-2.35846702793096 53.0907997041103)
183 8 2 8 0xE6100000010C82B9B41004534A40F97B9728ECDEF8BF POINT (-1.55442443710467 52.6485615618176)
184 4 2 6 0xE6100000010C8A8A301567434A409AFAF6A6232BFEBF POINT (-1.88553204746828 52.5265833365457)
185 9 2 4 0xE6100000010CBB7D019FD8404A40BD903C1DCA5902C0 POINT (-2.29384253350335 52.5066107518464)
186 8 2 4 0xE6100000010CF2EDF4D773134A406773A2484D9907C0 POINT (-2.94985443826447 52.1519727655358)
187 6 1 4 0xE6100000010C381064A1F6F849408310A651BCD10CC0 POINT (-3.60240997112311 51.94502656351)
188 2 3 4 0xE6100000010CD3FCB73E6AF3494087D7B17DB7950EC0 POINT (-3.82310388754826 51.9016798399331)
189 2 1 4 0xE6100000010C44BB08BD5EED4940C320C2BF4A9610C0 POINT (-4.14676952001918 51.8544536869654)
190 6 2 4 0xE6100000010C0124660902D8494019DDE9B866BC13C0 POINT (-4.93398560454741 51.6875621556028)
191 1 2 4 0xE6100000010CF135C7CD4DDD494082104C75780714C0 POINT (-5.00729544903527 51.7289368841847)
在调用 Math.Round():
时尝试将纬度和经度转换为 (double)var existing =( from r in DB.Database.Entities.OfType<DBWorkReport>()
where Math.Round((double)r.Location.Latitude ?? 0, 6) == Math.Round(latitude, 6)
&& Math.Round((double)r.Location.Longitude ?? 0, 6) == Math.Round(longitude, 6)
&& r.WorkType.Description == type
select r).FirstOrDefault();
确保 'longitude' 和 'latitude' 也是 'double' 类型。
visual studio 突出显示的代码实际上与错误无关,它是使用 GDAL 库将北和东参考重新投影到 [= 的代码的较早部分15=],代码本身可以正常工作,但在我删除该代码后,该库的某些内容显然导致了错误,因为它在第二次停止时停止了该代码
using (OSGeo.OSR.SpatialReference inSpatialRef = new OSGeo.OSR.SpatialReference(""))
using (OSGeo.OSR.SpatialReference outSpatialRef = new OSGeo.OSR.SpatialReference(""))
{
inSpatialRef.ImportFromEPSG(form);
outSpatialRef.ImportFromEPSG(to);
using (OSGeo.OSR.CoordinateTransformation coordTransform = new OSGeo.OSR.CoordinateTransformation(inSpatialRef, outSpatialRef))
{
coordTransform.TransformPoint(cord);
}
}
return cord;
这表明问题出在作为 GDAL 包的一部分提供的osr_csharp.dll