[gdal-dev] GDAL / OGR 64bit - PINVOKE Exception

Jordan Stoffer jstoffer at rscusa.com
Tue Apr 19 19:39:30 EDT 2011



From: Jordan Stoffer
Sent: Tuesday, April 19, 2011 4:38 PM
To: Jay Jennings
Cc: gdal-dev at lists.osgeo.org
Subject: RE: GDAL / OGR 64bit - PINVOKE Exception

Here is an example of the code we are using. It is a very simple example and breaks as soon as we try to register the GDAL driver. Hopefully this can provide some insight as to what is happening. Thanks!

            OSGeo.GDAL.Gdal.AllRegister();
            OSGeo.GDAL.Dataset me = OSGeo.GDAL.Gdal.Open(@"C:\Projects\LEAPdbI\demo\Data\PHXr14c27.tif", Access.GA_ReadOnly);

This code breaks on the very first line.
From: gdal-dev-bounces at lists.osgeo.org [mailto:gdal-dev-bounces at lists.osgeo.org] On Behalf Of Jordan Stoffer
Sent: Tuesday, April 19, 2011 2:41 PM
To: Jay Jennings
Cc: gdal-dev at lists.osgeo.org
Subject: [gdal-dev] RE: GDAL / OGR 64bit - PINVOKE Exception

Thanks for the response Jay. Unfourtunately, I have already tried each configuration (x64, Any CPU, and x86) with the same results. I have also tried both Release and Debug mode for each configuration. Still no luck...

From: Jay Jennings [mailto:Jennings.Jay at geoeye.com]
Sent: Tuesday, April 19, 2011 2:06 PM
To: Jordan Stoffer
Subject: RE: GDAL / OGR 64bit - PINVOKE Exception

I have the same setup as you (64-bit Win7, VS2010) and when I had that same msg (albeit with GDAL, not OGR), the fix was to go to the Properties page of the executable, Build tab, and set "Platform Target" to "Any CPU".  Good luck.
.........................................................
Jay Jennings
Senior Software Developer
(NASDAQ: GEOY)


From: gdal-dev-bounces at lists.osgeo.org [mailto:gdal-dev-bounces at lists.osgeo.org] On Behalf Of Jordan Stoffer
Sent: Tuesday, April 19, 2011 4:55 PM
To: gdal-dev at lists.osgeo.org
Cc: Kris Pribadi
Subject: [gdal-dev] GDAL / OGR 64bit - PINVOKE Exception

Hello,

I am getting the message "The type initializer for 'OSGeo.OGR.OgrPINVOKE' threw an exception." in my C# program that is referencing the ogr_csharp.dll file.  When trying to instantiate a class that is extended from the OGR.Geometry class . After doing some research it appears that the issue is being caused by 64bit vs. 32bit architecture. I am running a 64bit Windows 7 machine using Visual Studio 2010. I have tried switching the project / solution configuration to be x86 as well as Any CPU with the same results. I have also used the 64bit builds on http://www.gisinternals.com/sdk/ with the same results. The full stack trace is below. Any ideas?


System.Transactions Critical: 0 : <TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Critical"><TraceIdentifier>http://msdn.microsoft.com/TraceCodes/System/ActivityTracing/2004/07/Reliability/Exception/Unhandled</TraceIdentifier><Description>Unhandled exception</Description><AppDomain>SimDBI.vshost.exe</AppDomain><Exception><ExceptionType>System.TypeInitializationException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType><Message>The type initializer for 'OSGeo.OGR.OgrPINVOKE' threw an exception.</Message><StackTrace>   at OSGeo.OGR.OgrPINVOKE.new_Geometry(Int32 jarg1, String jarg2, Int32 jarg3, IntPtr jarg4, String jarg5)
   at OSGeo.OGR.Geometry..ctor(wkbGeometryType type)
   at SimDBI.Coordinate..ctor() in C:\Projects\SimDBI\SimDBI\Coordinate.cs:line 42
   at SimDBI.Test.Main() in C:\Projects\SimDBI\SimDBI\Test.cs:line 16
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()</StackTrace><ExceptionString>System.TypeInitializationException: The type initializer for 'OSGeo.OGR.OgrPINVOKE' threw an exception. ---&amp;gt; System.TypeInitializationException: The type initializer for 'SWIGExceptionHelper' threw an exception. ---&amp;gt; System.DllNotFoundException: Unable to load DLL 'ogr_wrap': The operating system cannot run . (Exception from HRESULT: 0x800700B6)
   at OSGeo.OGR.OgrPINVOKE.SWIGExceptionHelper.SWIGRegisterExceptionCallbacks_Ogr(ExceptionDelegate applicationDelegate, ExceptionDelegate arithmeticDelegate, ExceptionDelegate divideByZeroDelegate, ExceptionDelegate indexOutOfRangeDelegate, ExceptionDelegate invalidCastDelegate, ExceptionDelegate invalidOperationDelegate, ExceptionDelegate ioDelegate, ExceptionDelegate nullReferenceDelegate, ExceptionDelegate outOfMemoryDelegate, ExceptionDelegate overflowDelegate, ExceptionDelegate systemExceptionDelegate)
   at OSGeo.OGR.OgrPINVOKE.SWIGExceptionHelper..cctor()
   --- End of inner exception stack trace ---
   at OSGeo.OGR.OgrPINVOKE.SWIGExceptionHelper..ctor()
   at OSGeo.OGR.OgrPINVOKE..cctor()
   --- End of inner exception stack trace ---
   at OSGeo.OGR.OgrPINVOKE.new_Geometry(Int32 jarg1, String jarg2, Int32 jarg3, IntPtr jarg4, String jarg5)
   at OSGeo.OGR.Geometry..ctor(wkbGeometryType type)
   at SimDBI.Coordinate..ctor() in C:\Projects\SimDBI\SimDBI\Coordinate.cs:line 42
   at SimDBI.Test.Main() in C:\Projects\SimDBI\SimDBI\Test.cs:line 16
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()</ExceptionString><InnerException><ExceptionType>System.TypeInitializationException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType><Message>The type initializer for 'SWIGExceptionHelper' threw an exception.</Message><StackTrace>   at OSGeo.OGR.OgrPINVOKE.SWIGExceptionHelper..ctor()
   at OSGeo.OGR.OgrPINVOKE..cctor()</StackTrace><ExceptionString>System.TypeInitializationException: The type initializer for 'SWIGExceptionHelper' threw an exception. ---&amp;gt; System.DllNotFoundException: Unable to load DLL 'ogr_wrap': The operating system cannot run . (Exception from HRESULT: 0x800700B6)
   at OSGeo.OGR.OgrPINVOKE.SWIGExceptionHelper.SWIGRegisterExceptionCallbacks_Ogr(ExceptionDelegate applicationDelegate, ExceptionDelegate arithmeticDelegate, ExceptionDelegate divideByZeroDelegate, ExceptionDelegate indexOutOfRangeDelegate, ExceptionDelegate invalidCastDelegate, ExceptionDelegate invalidOperationDelegate, ExceptionDelegate ioDelegate, ExceptionDelegate nullReferenceDelegate, ExceptionDelegate outOfMemoryDelegate, ExceptionDelegate overflowDelegate, ExceptionDelegate systemExceptionDelegate)
   at OSGeo.OGR.OgrPINVOKE.SWIGExceptionHelper..cctor()
   --- End of inner exception stack trace ---
   at OSGeo.OGR.OgrPINVOKE.SWIGExceptionHelper..ctor()
   at OSGeo.OGR.OgrPINVOKE..cctor()</ExceptionString><InnerException><ExceptionType>System.DllNotFoundException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType><Message>Unable to load DLL 'ogr_wrap': The operating system cannot run . (Exception from HRESULT: 0x800700B6)</Message><StackTrace>   at OSGeo.OGR.OgrPINVOKE.SWIGExceptionHelper.SWIGRegisterExceptionCallbacks_Ogr(ExceptionDelegate applicationDelegate, ExceptionDelegate arithmeticDelegate, ExceptionDelegate divideByZeroDelegate, ExceptionDelegate indexOutOfRangeDelegate, ExceptionDelegate invalidCastDelegate, ExceptionDelegate invalidOperationDelegate, ExceptionDelegate ioDelegate, ExceptionDelegate nullReferenceDelegate, ExceptionDelegate outOfMemoryDelegate, ExceptionDelegate overflowDelegate, ExceptionDelegate systemExceptionDelegate)
   at OSGeo.OGR.OgrPINVOKE.SWIGExceptionHelper..cctor()</StackTrace><ExceptionString>System.DllNotFoundException: Unable to load DLL 'ogr_wrap': The operating system cannot run . (Exception from HRESULT: 0x800700B6)
   at OSGeo.OGR.OgrPINVOKE.SWIGExceptionHelper.SWIGRegisterExceptionCallbacks_Ogr(ExceptionDelegate applicationDelegate, ExceptionDelegate arithmeticDelegate, ExceptionDelegate divideByZeroDelegate, ExceptionDelegate indexOutOfRangeDelegate, ExceptionDelegate invalidCastDelegate, ExceptionDelegate invalidOperationDelegate, ExceptionDelegate ioDelegate, ExceptionDelegate nullReferenceDelegate, ExceptionDelegate outOfMemoryDelegate, ExceptionDelegate overflowDelegate, ExceptionDelegate systemExceptionDelegate)
   at OSGeo.OGR.OgrPINVOKE.SWIGExceptionHelper..cctor()</ExceptionString></InnerException></InnerException></Exception></TraceRecord>


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20110419/69aee003/attachment-0001.html


More information about the gdal-dev mailing list