ThinkGeo.com    |     Documentation    |     Premium Support

Mapsuite 10.0 Exception when usng Oracle

Hi,

i’ve installed MapSuite 10 and activated my license. I’ve used Nuget to include Mapsuite WPF in my Project, i also included Mapsuite Oracle with dependencies.

I use the following code to add an OracelFeatureLayer to my map:

  var oracleOverlay = new OracleFeatureLayer( "Data Source=xx;User Id=xx;Password=xx;", "xx", "xx");
  oracleOverlay.ZoomLevelSet.ZoomLevel12.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
  oracleOverlay.ZoomLevelSet.ZoomLevel12.DefaultLineStyle = LineStyles.Highway1;
  var oracleOverlayOverlay = new LayerOverlay( );
  oracleOverlayOverlay.Layers.Add( "Test", oracleOverlay );
  wpfMap1.Overlays.Add( "Test", oracleOverlayOverlay );

When i run that code i get an exception with the following stacktrace:

System.NullReferenceException was unhandled
HResult=-2147467261
Message=Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.
Source=ThinkGeo.MapSuite.Wpf
StackTrace:
bei ThinkGeo.MapSuite.Wpf.Tile.<>c__DisplayClass121_0.b__0()
bei System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
bei MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
bei System.Windows.Threading.DispatcherOperation.InvokeImpl()
bei System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
bei System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
bei System.Windows.Threading.DispatcherOperation.Invoke()
bei System.Windows.Threading.Dispatcher.ProcessQueue()
bei System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
bei MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
bei MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
bei System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
bei MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
bei System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
bei MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
bei MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
bei System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
bei System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
bei System.Windows.Threading.Dispatcher.Run()
bei System.Windows.Application.RunDispatcher(Object ignore)
bei System.Windows.Application.RunInternal(Window window)
bei System.Windows.Application.Run(Window window)
bei System.Windows.Application.Run()
bei Rwe.Wabis.Versickerung.WPF.App.Main() in c:\Projekte_Test\WABIS\appl\entw\WART01\dotnet\WABIS\Versickerung\WPF.Tester\obj\Debug\App.g.cs:Zeile 0.
bei System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
bei System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
bei Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
bei System.Threading.ThreadHelper.ThreadStart_Context(Object state)
bei System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
bei System.Threading.ThreadHelper.ThreadStart()
InnerException:

This doesn’t really help me. as it does not show the real cause of the error. I tried giving a wrong password to see if the error changes, but it remains the same.

How do i get to know the real error?

Regards,
Andreas

Hi Andreas,

We should met an exception last week, we had fixed that in the latest prerelease version.

Could you please let us know your detail version of the ThinkGeo.MapSuite.Layers.Oracle and MapSuiteDependency-Oracle? If you found which version is not the latest one please upload that and try again.

Please notice the MapSuiteDependency-Oracle get higher version than other package, please get the beta002 version.

If that still don’t works for you please let us know.

Regards,

Don

Hi Don,

i did:

  1. Create a new WPF-Project
  2. use nuget to install Mapsuite WPF
  3. use Nuget to install Oracle Laye
  4. use nuget to instll Oracle-dependencies

  1. Created a new wpfmap in XAML
  2. Wrote the following code in the code-behind:
public MainWindow( )
{
  InitializeComponent( );
  this.Loaded += MainWindow_Loaded;
}
void MainWindow_Loaded( object sender, RoutedEventArgs e )
{
  wpfMap1.MapUnit = GeographyUnit.Meter;
  InitOracleLayer( );
}
void InitOracleLayer( )
{
  var oracleOverlay = new OracleFeatureLayer( "Data Source=xx;User Id=xx;Password=xx;", "xx", "xx" );
  oracleOverlay.ZoomLevelSet.ZoomLevel12.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
  oracleOverlay.ZoomLevelSet.ZoomLevel12.DefaultLineStyle = LineStyles.Highway1;
  var oracleOverlayOverlay = new LayerOverlay( );
  oracleOverlayOverlay.Layers.Add( "Test", oracleOverlay );
  wpfMap1.Overlays.Add( "Test", oracleOverlayOverlay );
}

At runtime, still the same exception is shown

Regards,
Andreas

Hi Andreas,

Today I try to create a sample based on your steps, but still failed to reproduce that.

As below is my steps:

  1. Build a simple WPF project base on this guide: http://wiki.thinkgeo.com/wiki/map_suite_project_template_guide
  2. Download the latest version of two Oracle package from NuGet
  3. Update all the mapsuite package to the latest version from NuGet
  4. Use the code as below to test, I think which should just the same like yours:

private const string connectionString = “User ID=xx;Password=xx;Data Source=xx;”;

    private void map_Loaded(object sender, RoutedEventArgs e)
    {
        map.MapUnit = ThinkGeo.MapSuite.GeographyUnit.DecimalDegree;
        var oracleFeatureLayer = new OracleFeatureLayer(connectionString, "xx", "xx");
        oracleFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = new AreaStyle(new GeoSolidBrush(GeoColor.SimpleColors.Copper));
        oracleFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = new LineStyle(new GeoPen(new GeoSolidBrush(GeoColor.SimpleColors.Copper), 2.0f));
        oracleFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

        oracleFeatureLayer.Open();
        var extent = oracleFeatureLayer.GetBoundingBox();
        oracleFeatureLayer.Close();

        map.CurrentExtent = extent;

        LayerOverlay overlay = new LayerOverlay();
        overlay.Layers.Add(oracleFeatureLayer);

        map.Overlays.Add(overlay);
        map.Refresh();
    }

Could you please double check that? And if you still met the same issue, I think we need a sample to reproduce that.

Regards,

Don

Hey Don,

I believe I am running into the same problem as Andreas.

Using Visual Studio 2012 with the references updated to latest pre-release I modified the ArcGISServerRestLayer sample code to include the following after creating the GIS layer
try
{
OracleFeatureLayer fl = new OracleFeatureLayer(“user id=x;password=x;data source=ip/sid”, “tableName”, “Id”);
fl.Open();
}
catch(Exception err)
{
MessageBox.Show(err.Message);
}

The exception is thrown on the open :

{System.NullReferenceException: Object reference not set to an instance of an object.
at ThinkGeo.MapSuite.Layers.OracleFeatureSource.get_ConnectionString()
at ThinkGeo.MapSuite.Layers.OracleFeatureSource.OpenCore()
at ThinkGeo.MapSuite.Layers.FeatureSource.Open()
at ThinkGeo.MapSuite.Layers.FeatureLayer.OpenCore()
at ThinkGeo.MapSuite.Layers.Layer.Open()
at ArcGISServerRestLayer.MainWindow.Window_Loaded(Object sender, RoutedEventArgs e) in c:\projects\ArcGISServerRestLayerSample-ForWPF-master\ArcGISServerRestLayer\MainWindow.xaml.cs:line 34}

Same result regardless of whether or not the connection info is correct or not.

I turned on the break when exceptions are thrown and this is coming back from the OracleFeatureLayer constructor

Managed Debugging Assistant ‘BindingFailure’ has detected a problem in ‘C:\projects\ArcGISServerRestLayerSample-ForWPF-master\ArcGISServerRestLayer\bin\Debug\ArcGISServerRestLayer.vshost.exe’.

Additional information: The assembly with display name ‘ThinkGeo.MapSuite’ failed to load in the ‘LoadFrom’ binding context of the AppDomain with ID 1. The cause of the failure was: System.IO.FileNotFoundException: Could not load file or assembly ‘ThinkGeo.MapSuite, Version=10.0.0.0, Culture=neutral, PublicKeyToken=null’ or one of its dependencies. The system cannot find the file specified.

View Details shows this “The name ‘$exception’ does not exist in the current context”

Hi Richard,

It looks your exception is: Could not load file or assembly ‘ThinkGeo.MapSuite, Version=10.0.0.0, Culture=neutral, PublicKeyToken=null’ or one of its dependencies

I guess that’s because the ArcGISServerRestLayer sample hadn’t reference enough package for the Oracle layer.

Please try the attached sample 8523.zip (11.4 KB)

Regards,

Don

Don,

Sample code fails in the same manner. The assembly in question is in the location that it identifies. Constructor for OracleFeatueSource also throws this exception. Keep in mind only reason I am aware of the exception is that I have the break on thrown exceptions turned on. The exception in question is apparently caught and handled within the constructor.

Not sure if relevant or not but I am on a Windows 7 machine running java 1.8.0_91

Hi Richard,

We reproduce that today in the other machine, that should because the package cache in local. Because we double check the latest version in NuGet, it had been fixed.

So please do something like this:

  1. Delete all packages in the “packages” folder in your projection folder.
  2. Delete the bin and obj folder
  3. Delete all packages in this folder: C:\Users\user\AppData\Local\NuGet\Cache

And you can also choose to uninstall the packages from project before that, then install them from network after that.

I think that should fixed your issue.

Regards,

Don

Don,

I tried all those steps with the sample you sent. I tried the stable version and the pre-release versions deleting the contetns of the directories you specified. Unfortunately none of that worked.

Hi Richard,

Please also update this version: ThinkGeo MapSuite Oracle Layer 11.0.0-beta002, then it should works.

Regards,

Don

Thanks Don. the latest Oracle Layer fixed my problem

Hi Richard,

I am glad to hear that works.

Regards,

Don

Hey Don, I spoke too soon. The original issue has been resolved, but now I have encountered another problem.

We are receiving the following exception when calling open on an oracleFeatrueLayer

System.AccessViolationException occurred
_HResult=-2147467261
_message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
HResult=-2147467261
IsTransient=false
Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
InnerException:

The info from the debugger when the exception is thrown is the following:

A first chance exception of type ‘System.AccessViolationException’ occurred in Oracle.DataAccess.dll

Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

Initially we were missing spatial indexes on our data and did not encounter this issue on open – but had problems later when trying to get a bounding rectangle… The above started occurring after creating the spatial indexes. At this point we have tried 3 different datasets all with the same results. Furthermore I modified the sample you attached earlier with the same results. All libraries at this point are the most recent pre-release versions.

Hi Richard,

I tried to reproduced that but failed.

I deleted all the cached packaged, then update all packages to the latest version.

It still works well without exception.

Could you please try to reproduce that based on the sample project I sent in this post, and sent the project to us so we can see where is the problem?

Regards,

Don

Attached is the requested project. I cannot give you access to our data, so the connection and table info are not set,
Exception occurs when Open is called. This does look like a dll mismatch, but I have cleared out the nugget cache, and removed the packages directory without any change in behavior

Hi Richard,

We tried in different machines with your modified project, but failed to reproduce that.

We guess that maybe related with the cached packages of NuGet, please do something follow this steps:

  1. Delete all MapSuite’s packages here: C:\Users\user.nuget\packages and C:\Users\user\AppData\Local\NuGet\Cache

  2. Delete the “packages”, “obj” and “bin” folders in your project.

  3. Build your project and test again.

Please let us know your test result.

BTW, your uploaded sample contains your private connection string, it looks you forget delete that, you should want to edit your reply for delete that.

Regards,

Don

Hi Richard,

We reproduced your exception in one of our machine.

We compare the project files, and found that should caused by the solution file.

First I want to double check your VS version, because from your project, the referenced “Debug Source Files” point to the folder “C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC”. You can view that like this: Right click on solution, select “Properties”, find the “Debug Source Files” under “Common Properties” tree node.

We found with the same project, remove the solution which from you, then create new one under VS2015 or VS2017, it works well. The reason why the last machine throw exception is because the target folder point to “Microsoft Visual Studio 12.0\VC” but this machine had uninstalled that version, so the target files don’t works.

I guess maybe you met the same problem.

Please try to remove your currently solution file, use VS build a new solution file and double check it point to valid folder, then try everything again.

Wish that’s helpful.

Regards,

Don

Problem still exists with a new project created under VS2015 and having removed the nugget directories mentioned.

We are going to try and reproduce the problem on a “clean” machine. I will let you know what that turns up.

Hi Richard,

We created one Oracle Sample and upload to GitHub several days ago. You can download and build on you machine. Wish that’s helpful.

If you have any found in your new machine, please let’s know that.

Thanks
Mark