我們正在使用wpf,C#和Prism v6.1.0.0構建帶有視覺工作室2017的應用程序。我們有一個三維視圖,它是一個Esri .net運行時SceneView。我們希望使用GetElevationAsync(mapPoint)函數從DTED 0級數據獲取高程數據。在僅使用Esri SceneView的獨立應用程序中,如果SceneView處於活動狀態,則GetElevationAsync(mapPoint)函數適用於SceneView和MapView。這也使用FileElevationSource並在DTED級別0中加載到FileElevationSource中,然後將其添加到SceneView.Scene.Surface中。Prism和Esri GetElevationAsync(mapPoint)
我們遇到的問題是,當我們嘗試調用GetElevationAsync(mapPoint)時,我們得到System.AccessViolationException。有沒有其他人嘗試過使用ESRi的.net運行時和Prism來創建一個使用GetElevationAsync(mapPoint)函數的SceneView應用程序?
什麼是具有多視圖和主外殼的棱鏡應用程序。 SceneView模塊有一個服務,並使用此服務器將DTED 0級數據加載到SceneView.Scene.Surface中。我已將所有功能移至SceneViewView,並且仍然存在相同的訪問錯誤。調用線程是主要的應用程序線程。我發佈了錯誤和一些代碼片段。 我在Prism應用程序中使用的代碼與我在使用所有相同控件但不是Prism體系結構的簡單WPF應用程序中使用的代碼相同。它工作的很好,我可以通過激活Sceneview並將地圖視圖中的地圖傳遞到GetElevationAsync函數中而無需任何問題來獲取電子地圖數據。被傳遞
private void OnSceneViewViewLoaded(object sender, RoutedEventArgs e)
{
SceneViewService = UnityContainer.Resolve<ISceneViewService>();
string elevationSourcePath = System.Environment.GetEnvironmentVariable("SHELL") + "\\Resources\\Terrain\\DTED\\Level0\\";
AddElevationSources(elevationSourcePath);
mSceneView.MouseMove += OnSceneViewMouseMove;
}
private void OnSceneViewMouseMove(object sender, MouseEventArgs e)
{
{
Point screenPoint = e.GetPosition(mSceneView);
double elevation = 0.0;
MapPoint point = mSceneView.ScreenToLocation(screenPoint);
if (point != null)
{
MapPoint mapPoint = GeometryEngine.Project(point, SpatialReferences.Wgs84) as MapPoint;
elevation = GetElevation(mapPoint).Result;
if (!Double.IsNaN(elevation))
{
mElevationStatusBarTextBlock.Text = elevation.ToString();
}
}
}
}
public void AddElevationSources(string elevationSourcePath)
{
FilenameCollection mFilenameCollection = new FilenameCollection();
List<String> files = new List<String>();
try
{
files = DirSearch(elevationSourcePath);
foreach (String file in files)
mFilenameCollection.Add(file);
mFileElevationSource.Filenames = mFilenameCollection;
mFileElevationSource.ID = "Elevation Source";
mSceneView.Scene.Surface.Add(mFileElevationSource);
mFileElevationSource.IsEnabled = true;
}
catch (Exception excpt)
{
Console.WriteLine("AddElevationSources, ElevationSourceService " + excpt.Message);
}
}
public List<String> DirSearch(string sourceDirectory)
{
List<String> files = new List<String>();
try
{
foreach (string file in Directory.GetFiles(sourceDirectory, "*.dt0"))
{
files.Add(file);
}
foreach (string directory in Directory.GetDirectories(sourceDirectory))
{
files.AddRange(DirSearch(directory));
}
}
catch (Exception excpt)
{
Console.WriteLine("DirSearch, AddElevationSources " + excpt.Message);
}
return files;
}
地圖點數據「的MapPoint = {MapPoint的[X = 4.54778361440582,Y = 27.7940801510867,Z = 5.58793544769287E-09,WKID = 4326]}」
public async Task<double> GetElevation(MapPoint mapPoint)
{
double elevation = 0.0;
try
{
if (!Double.IsNaN(mapPoint.X) && !Double.IsNaN(mapPoint.Y))
{
elevation = await mFileElevationSource.GetElevationAsync(mapPoint);
if (Double.IsNaN(elevation))
elevation = 0;
}
}
catch (Exception excpt)
{
Console.WriteLine("Task<double> GetElevation, ElevationSourceModule " + excpt.Message);
}
return elevation;
}
}
System.AccessViolationException發生 HResult = 0x80004003 消息=試圖讀取或寫入受保護的內存。這通常表明其他內存已損壞。 源= Esri.ArcGISRuntime 堆棧跟蹤: 在runtimeCoreNet.CoreLocalElevationRaster.LocalElevationLayerPickElevation(IntPtr的pNativeElevationLayer,雙人的x,雙Y,雙人& Z) 在Esri.ArcGISRuntime.Controls.FileElevationSource.GetElevationAsync在SceneViewModule.Views(MapPoint的點) .SceneViewView.SceneViewView.d__19.MoveNext()in \ SceneViewModule \ Views \ SceneViewView \ SceneViewView.xaml.cs:line 141
只是好奇你爲什麼使用棱鏡第四版?你知道棱鏡6.3已經出來了,4不再被支持或者維護了嗎? –
您可以在項目設置中啓用「本地調試」,並共享發生崩潰時獲得的調用堆棧嗎?它可能會讓我繼續下去。 – dotMorten
是的,我今天將啓用「本機調試」並查看結果。好主意。 –