2016-05-31 45 views
1

Ich bin mit diesem CodeWarum erhalte ich 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(); 

der Fehler tritt auch auf einem einfachen DB.Database.Entities.ToList();

wo

DB ist

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); 
     } 
    } 

Entities ist

public virtual DbSet<DBEntity> Entities { get; set; } 

DBWorkReport ist

public partial class DBWorkReport : DBEntity 

und r.Location ist DBGeography

012.

aber wenn ich es laufen, seine werfen

FatalExecutionEngineError occurred HResult=-2146233082
Message=Exception of type 'System.ExecutionEngineException' was thrown. InnerException:

enter image description here

MSDN zu zitieren:

FatalExecutionEngineError: This type previously indicated an unspecified fatal error in the runtime. The runtime no longer raises this exception so this type is obsolete.

an einem anderen Punkt Ich rufe erfolgreich diesen Code, so dass es nicht der Fall ist scheint, dass das Problem ist die Verbindung zu SQLServer

lookups = DB.Database?.Lookups.Where(l=>l.companyid==DB.CompanyID).ToLookup(g => g.LookupTypeId) ; 

also was funktioniert nicht?

Update:

von DB

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) 
+0

Ist 'r.Location' vielleicht null? – rene

+1

Haben Sie die innere Ausnahme für Details überprüft? –

+0

@rene hinzugefügt Inhalt des Standorts keine Nullen vorhanden – MikeT

Antwort

0

Der Code, der von Visual Studio hervorgehoben wurde, hatte eigentlich nichts mit dem Fehler zu tun, es war ein früherer Codeabschnitt, der die GDAL-Bibliotheken zum erneuten Projizieren der Nord- und Ostverweise auf Long/Lat, den Code, verwendete selbst arbeitete aber etwas über die Bibliothek deutlich wurde den Fehler verursacht, da es die zweite aufhörte ich diesen Code entfernt

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; 

was darauf schließen lässt, dass das Problem in der osr_csharp.dll als Teil des GDAL Paket

vorgesehen ist
0

Versuchen Gießen Breite und Länge zu (double), wenn Math.Round() aufrufen:

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(); 

stellen Sie sicher, 'Länge' und 'Breite' ist auch vom Typ 'doppelt'.

+0

, die eine InvalidCastException wäre und alle Longs und Lats sind bereits verdoppelt Danke fürs ausprobieren – MikeT