<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 12 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal>Hello,<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>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 <a href="http://www.gisinternals.com/sdk/">http://www.gisinternals.com/sdk/</a> with the same results. The full stack trace is below. Any ideas?<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'>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)<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'> at OSGeo.OGR.Geometry..ctor(wkbGeometryType type)<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'> at SimDBI.Coordinate..ctor() in C:\Projects\SimDBI\SimDBI\Coordinate.cs:line 42<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'> at SimDBI.Test.Main() in C:\Projects\SimDBI\SimDBI\Test.cs:line 16<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'> at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'> at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'> at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'> at System.Threading.ThreadHelper.ThreadStart_Context(Object state)<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'> at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'> at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'> 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)<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'> 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)<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'> at OSGeo.OGR.OgrPINVOKE.SWIGExceptionHelper..cctor()<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'> --- End of inner exception stack trace ---<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'> at OSGeo.OGR.OgrPINVOKE.SWIGExceptionHelper..ctor()<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'> at OSGeo.OGR.OgrPINVOKE..cctor()<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'> --- End of inner exception stack trace ---<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'> at OSGeo.OGR.OgrPINVOKE.new_Geometry(Int32 jarg1, String jarg2, Int32 jarg3, IntPtr jarg4, String jarg5)<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'> at OSGeo.OGR.Geometry..ctor(wkbGeometryType type)<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'> at SimDBI.Coordinate..ctor() in C:\Projects\SimDBI\SimDBI\Coordinate.cs:line 42<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'> at SimDBI.Test.Main() in C:\Projects\SimDBI\SimDBI\Test.cs:line 16<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'> at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'> at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'> at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'> at System.Threading.ThreadHelper.ThreadStart_Context(Object state)<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'> at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'> at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'> 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()<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'> 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)<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'> 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)<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'> at OSGeo.OGR.OgrPINVOKE.SWIGExceptionHelper..cctor()<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'> --- End of inner exception stack trace ---<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'> at OSGeo.OGR.OgrPINVOKE.SWIGExceptionHelper..ctor()<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'> 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)<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'> 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)<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'> 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)<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'> at OSGeo.OGR.OgrPINVOKE.SWIGExceptionHelper..cctor()</ExceptionString></InnerException></InnerException></Exception></TraceRecord><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'><o:p> </o:p></span></p><p class=MsoNormal><o:p> </o:p></p></div></body></html>