[gdal-dev] Need solution for C# setup, with error at OSGeo.OGR registration

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[gdal-dev] Need solution for C# setup, with error at OSGeo.OGR registration

czeng
​Hello all,

I am trying to setup the GDAL in C#.NET 2015, with an error at the registration of the Ogr. A previous post stated the exact same problem but without a solution, I tried to reply in that post but failed,thus send this email instead. 

That previous post described my problem very well:  
"I am using ogr_csharp.dll in my c# program. See the following code snippet: 
using OSGeo.OGR; 
namespace Test 
{ 
    public class Test 
    { 
        public Test() 
        { 
                ... 
                  Ogr.RegisterAll(); 
        }       
    } 
} 
Then the following exception message was thrown out when the program is executed: 
{"The type initializer for 'OSGeo.OGR.OgrPINVOKE' threw an exception."}         
System.Exception {System.TypeInitializationException} 
Does anyone know how to resolve this issue? "

Some more details for my case. My steps are: 
- downloaded the stable or daily stable release (same error later) from here
- added the "...\bin" and "...\bin\gdal\csharp" to Environment Variable, setup a sample project, 
- add the 4 "###sharp.dll" from csharp folder to project reference. 
- import namespace:  using OSGeo.OGR; using OSGeo.OSR;  and add a simple line "Ogr.RegisterAll(); " 

Then I can successfully build the project, but with the following error msg. I tried all possible solutions by Google plus this forum such as this and this
test all the x64/x86 , debug/release, switches, no luck. 

Any comment is appreciated, thank you! 

Chui 



--------------------------error message -------------------------- 

Unhandled Exception: System.TypeInitializationException: The type initializer fo 
r 'OSGeo.OGR.OgrPINVOKE' threw an exception. ---> System.TypeInitializationExcep 
tion: The type initializer for 'SWIGExceptionHelper' threw an exception. ---> Sy 
stem.BadImageFormatException: An attempt was made to load a program with an inco 
rrect format. (Exception from HRESULT: 0x8007000B) 
   at OSGeo.OGR.OgrPINVOKE.SWIGExceptionHelper.SWIGRegisterExceptionCallbacks_Og 
r(ExceptionDelegate applicationDelegate, ExceptionDelegate arithmeticDelegate, E 
xceptionDelegate divideByZeroDelegate, ExceptionDelegate indexOutOfRangeDelegate 
, ExceptionDelegate invalidCastDelegate, ExceptionDelegate invalidOperationDeleg 
ate, ExceptionDelegate ioDelegate, ExceptionDelegate nullReferenceDelegate, Exce 
ptionDelegate outOfMemoryDelegate, ExceptionDelegate overflowDelegate, Exception 
Delegate 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.RegisterAll() 
   at OSGeo.OGR.Ogr.RegisterAll() 
   at TestProj.Main(String[] args) in \user\Downloads\Workspace\TestProj\project.cs:line 47


and also the following log info: 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities\14.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.dll'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities.Sync\14.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.Sync.dll'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.Debugger.Runtime\14.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Debugger.Runtime.dll'.
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded '\user\Downloads\Gdal_folder\TestProj\bin\Debug\TestProj.vshost.exe'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml.Linq\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.Linq.dll'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Data.DataSetExtensions\v4.0_4.0.0.0__b77a5c561934e089\System.Data.DataSetExtensions.dll'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Microsoft.CSharp\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.CSharp.dll'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_64\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Net.Http\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Net.Http.dll'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll'. Cannot find or open the PDB file. 
The thread 0x2228 has exited with code 0 (0x0). 
The thread 0x1b30 has exited with code 0 (0x0). 
The thread 0x2a64 has exited with code 0 (0x0). 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded '\user\Downloads\Gdal_folder\TestProj\bin\Debug\TestProj.exe'. Symbols loaded. 
The thread 0x2c20 has exited with code 0 (0x0). 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded '\user\Downloads\Gdal_folder\TestProj\bin\Debug\ogr_csharp.dll'. Module was built without symbols. 
Exception thrown: 'System.DllNotFoundException' in ogr_csharp.dll 
Exception thrown: 'System.TypeInitializationException' in ogr_csharp.dll 
Exception thrown: 'System.TypeInitializationException' in ogr_csharp.dll 
An unhandled exception of type 'System.TypeInitializationException' occurred in ogr_csharp.dll 
Additional information: The type initializer for 'OSGeo.OGR.OgrPINVOKE' threw an exception. 

The program '[2244] TestProj.vshost.exe' has exited with code 0 (0x0)


_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Need solution for C# setup, with error at OSGeo.OGR registration

Tamas Szekeres
Hi,

You probably have multiple dll dependencies availabe in the path. Try copying all the dependencies from the same package to the location where your excutable is running.

Best regards,

Tamas

Az iPhone-omról küldve

2017. aug. 1. dátummal, 17:08 időpontban C. Zeng <[hidden email]> írta:

​Hello all,

I am trying to setup the GDAL in C#.NET 2015, with an error at the registration of the Ogr. A previous post stated the exact same problem but without a solution, I tried to reply in that post but failed,thus send this email instead. 

That previous post described my problem very well:  
"I am using ogr_csharp.dll in my c# program. See the following code snippet: 
using OSGeo.OGR; 
namespace Test 
{ 
    public class Test 
    { 
        public Test() 
        { 
                ... 
                  Ogr.RegisterAll(); 
        }       
    } 
} 
Then the following exception message was thrown out when the program is executed: 
{"The type initializer for 'OSGeo.OGR.OgrPINVOKE' threw an exception."}         
System.Exception {System.TypeInitializationException} 
Does anyone know how to resolve this issue? "

Some more details for my case. My steps are: 
- downloaded the stable or daily stable release (same error later) from here
- added the "...\bin" and "...\bin\gdal\csharp" to Environment Variable, setup a sample project, 
- add the 4 "###sharp.dll" from csharp folder to project reference. 
- import namespace:  using OSGeo.OGR; using OSGeo.OSR;  and add a simple line "Ogr.RegisterAll(); " 

Then I can successfully build the project, but with the following error msg. I tried all possible solutions by Google plus this forum such as this and this
test all the x64/x86 , debug/release, switches, no luck. 

Any comment is appreciated, thank you! 

Chui 



--------------------------error message -------------------------- 

Unhandled Exception: System.TypeInitializationException: The type initializer fo 
r 'OSGeo.OGR.OgrPINVOKE' threw an exception. ---> System.TypeInitializationExcep 
tion: The type initializer for 'SWIGExceptionHelper' threw an exception. ---> Sy 
stem.BadImageFormatException: An attempt was made to load a program with an inco 
rrect format. (Exception from HRESULT: 0x8007000B) 
   at OSGeo.OGR.OgrPINVOKE.SWIGExceptionHelper.SWIGRegisterExceptionCallbacks_Og 
r(ExceptionDelegate applicationDelegate, ExceptionDelegate arithmeticDelegate, E 
xceptionDelegate divideByZeroDelegate, ExceptionDelegate indexOutOfRangeDelegate 
, ExceptionDelegate invalidCastDelegate, ExceptionDelegate invalidOperationDeleg 
ate, ExceptionDelegate ioDelegate, ExceptionDelegate nullReferenceDelegate, Exce 
ptionDelegate outOfMemoryDelegate, ExceptionDelegate overflowDelegate, Exception 
Delegate 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.RegisterAll() 
   at OSGeo.OGR.Ogr.RegisterAll() 
   at TestProj.Main(String[] args) in \user\Downloads\Workspace\TestProj\project.cs:line 47


and also the following log info: 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities\14.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.dll'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities.Sync\14.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.Sync.dll'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.Debugger.Runtime\14.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Debugger.Runtime.dll'.
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded '\user\Downloads\Gdal_folder\TestProj\bin\Debug\TestProj.vshost.exe'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml.Linq\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.Linq.dll'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Data.DataSetExtensions\v4.0_4.0.0.0__b77a5c561934e089\System.Data.DataSetExtensions.dll'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Microsoft.CSharp\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.CSharp.dll'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_64\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Net.Http\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Net.Http.dll'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll'. Cannot find or open the PDB file. 
The thread 0x2228 has exited with code 0 (0x0). 
The thread 0x1b30 has exited with code 0 (0x0). 
The thread 0x2a64 has exited with code 0 (0x0). 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded '\user\Downloads\Gdal_folder\TestProj\bin\Debug\TestProj.exe'. Symbols loaded. 
The thread 0x2c20 has exited with code 0 (0x0). 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded '\user\Downloads\Gdal_folder\TestProj\bin\Debug\ogr_csharp.dll'. Module was built without symbols. 
Exception thrown: 'System.DllNotFoundException' in ogr_csharp.dll 
Exception thrown: 'System.TypeInitializationException' in ogr_csharp.dll 
Exception thrown: 'System.TypeInitializationException' in ogr_csharp.dll 
An unhandled exception of type 'System.TypeInitializationException' occurred in ogr_csharp.dll 
Additional information: The type initializer for 'OSGeo.OGR.OgrPINVOKE' threw an exception. 

The program '[2244] TestProj.vshost.exe' has exited with code 0 (0x0)

_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev

_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Need solution for C# setup, with error at OSGeo.OGR registration

ewenger

Chui,

 

An example here is that you need to have proj.dll in the path so that gdal.dll will load from the PInvoke.  You can use dependency walker to find other dependencies.

 

From: gdal-dev [mailto:[hidden email]] On Behalf Of Tamas Szekeres
Sent: Tuesday, August 01, 2017 12:15 PM
To: C. Zeng
Cc: [hidden email]
Subject: Re: [gdal-dev] Need solution for C# setup, with error at OSGeo.OGR registration

 

Hi,

 

You probably have multiple dll dependencies availabe in the path. Try copying all the dependencies from the same package to the location where your excutable is running.

 

Best regards,

 

Tamas

Az iPhone-omról küldve


2017. aug. 1. dátummal, 17:08 időpontban C. Zeng <[hidden email]> írta:

​Hello all,

 

I am trying to setup the GDAL in C#.NET 2015, with an error at the registration of the Ogr. A previous post stated the exact same problem but without a solution, I tried to reply in that post but failed,thus send this email instead. 

 

That previous post described my problem very well:  

"I am using ogr_csharp.dll in my c# program. See the following code snippet: 
using OSGeo.OGR; 
namespace Test 
{ 
    public class Test 
    { 
        public Test() 
        { 
                ... 
                  Ogr.RegisterAll(); 
        }       
    } 
} 
Then the following exception message was thrown out when the program is executed: 
{"The type initializer for 'OSGeo.OGR.OgrPINVOKE' threw an exception."}         
System.Exception {System.TypeInitializationException} 
Does anyone know how to resolve this issue? "

 

Some more details for my case. My steps are: 

- downloaded the stable or daily stable release (same error later) from here
- added the "...\bin" and "...\bin\gdal\csharp" to Environment Variable, setup a sample project, 
- add the 4 "###sharp.dll" from csharp folder to project reference. 
- import namespace:  using OSGeo.OGR; using OSGeo.OSR;  and add a simple line "Ogr.RegisterAll(); " 

Then I can successfully build the project, but with the following error msg. I tried all possible solutions by Google plus this forum such as 
this and this
test all the x64/x86 , debug/release, switches, no luck. 

Any comment is appreciated, thank you! 

Chui 



--------------------------error message -------------------------- 

Unhandled Exception: System.TypeInitializationException: The type initializer fo 
r 'OSGeo.OGR.OgrPINVOKE' threw an exception. ---> System.TypeInitializationExcep 
tion: The type initializer for 'SWIGExceptionHelper' threw an exception. ---> Sy 
stem.BadImageFormatException: An attempt was made to load a program with an inco 
rrect format. (Exception from HRESULT: 0x8007000B) 
   at OSGeo.OGR.OgrPINVOKE.SWIGExceptionHelper.SWIGRegisterExceptionCallbacks_Og 
r(ExceptionDelegate applicationDelegate, ExceptionDelegate arithmeticDelegate, E 
xceptionDelegate divideByZeroDelegate, ExceptionDelegate indexOutOfRangeDelegate 
, ExceptionDelegate invalidCastDelegate, ExceptionDelegate invalidOperationDeleg 
ate, ExceptionDelegate ioDelegate, ExceptionDelegate nullReferenceDelegate, Exce 
ptionDelegate outOfMemoryDelegate, ExceptionDelegate overflowDelegate, Exception 
Delegate 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.RegisterAll() 
   at OSGeo.OGR.Ogr.RegisterAll() 
   at TestProj.Main(String[] args) in \user\Downloads\Workspace\TestProj\project.cs:line 47


and also the following log info: 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities\14.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.dll'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities.Sync\14.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.Sync.dll'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.Debugger.Runtime\14.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Debugger.Runtime.dll'.
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded '\user\Downloads\Gdal_folder\TestProj\bin\Debug\TestProj.vshost.exe'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml.Linq\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.Linq.dll'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Data.DataSetExtensions\v4.0_4.0.0.0__b77a5c561934e089\System.Data.DataSetExtensions.dll'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Microsoft.CSharp\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.CSharp.dll'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_64\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Net.Http\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Net.Http.dll'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll'. Cannot find or open the PDB file. 
The thread 0x2228 has exited with code 0 (0x0). 
The thread 0x1b30 has exited with code 0 (0x0). 
The thread 0x2a64 has exited with code 0 (0x0). 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded '\user\Downloads\Gdal_folder\TestProj\bin\Debug\TestProj.exe'. Symbols loaded. 
The thread 0x2c20 has exited with code 0 (0x0). 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded '\user\Downloads\Gdal_folder\TestProj\bin\Debug\ogr_csharp.dll'. Module was built without symbols. 
Exception thrown: 'System.DllNotFoundException' in ogr_csharp.dll 
Exception thrown: 'System.TypeInitializationException' in ogr_csharp.dll 
Exception thrown: 'System.TypeInitializationException' in ogr_csharp.dll 
An unhandled exception of type 'System.TypeInitializationException' occurred in ogr_csharp.dll 
Additional information: The type initializer for 'OSGeo.OGR.OgrPINVOKE' threw an exception. 

The program '[2244] TestProj.vshost.exe' has exited with code 0 (0x0)

_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev


_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Need solution for C# setup, with error at OSGeo.OGR registration

czeng
Thank you Eric and Tamas,

I have switched to python with Gdal, due to this setup issue with C# and other platform consideration. Thank you two for the help!.

Best,

Chui,

On Tue, Aug 8, 2017 at 4:18 PM, Eric Wenger ARA/SED <[hidden email]> wrote:

Chui,

 

An example here is that you need to have proj.dll in the path so that gdal.dll will load from the PInvoke.  You can use dependency walker to find other dependencies.

 

From: gdal-dev [mailto:[hidden email]] On Behalf Of Tamas Szekeres
Sent: Tuesday, August 01, 2017 12:15 PM
To: C. Zeng
Cc: [hidden email]
Subject: Re: [gdal-dev] Need solution for C# setup, with error at OSGeo.OGR registration

 

Hi,

 

You probably have multiple dll dependencies availabe in the path. Try copying all the dependencies from the same package to the location where your excutable is running.

 

Best regards,

 

Tamas

Az iPhone-omról küldve


2017. aug. 1. dátummal, 17:08 időpontban C. Zeng <[hidden email]> írta:

​Hello all,

 

I am trying to setup the GDAL in C#.NET 2015, with an error at the registration of the Ogr. A previous post stated the exact same problem but without a solution, I tried to reply in that post but failed,thus send this email instead. 

 

That previous post described my problem very well:  

"I am using ogr_csharp.dll in my c# program. See the following code snippet: 
using OSGeo.OGR; 
namespace Test 
{ 
    public class Test 
    { 
        public Test() 
        { 
                ... 
                  Ogr.RegisterAll(); 
        }       
    } 
} 
Then the following exception message was thrown out when the program is executed: 
{"The type initializer for 'OSGeo.OGR.OgrPINVOKE' threw an exception."}         
System.Exception {System.TypeInitializationException} 
Does anyone know how to resolve this issue? "

 

Some more details for my case. My steps are: 

- downloaded the stable or daily stable release (same error later) from here
- added the "...\bin" and "...\bin\gdal\csharp" to Environment Variable, setup a sample project, 
- add the 4 "###sharp.dll" from csharp folder to project reference. 
- import namespace:  using OSGeo.OGR; using OSGeo.OSR;  and add a simple line "Ogr.RegisterAll(); " 

Then I can successfully build the project, but with the following error msg. I tried all possible solutions by Google plus this forum such as 
this and this
test all the x64/x86 , debug/release, switches, no luck. 

Any comment is appreciated, thank you! 

Chui 



--------------------------error message -------------------------- 

Unhandled Exception: System.TypeInitializationException: The type initializer fo 
r 'OSGeo.OGR.OgrPINVOKE' threw an exception. ---> System.TypeInitializationExcep 
tion: The type initializer for 'SWIGExceptionHelper' threw an exception. ---> Sy 
stem.BadImageFormatException: An attempt was made to load a program with an inco 
rrect format. (Exception from HRESULT: 0x8007000B) 
   at OSGeo.OGR.OgrPINVOKE.SWIGExceptionHelper.SWIGRegisterExceptionCallbacks_Og 
r(ExceptionDelegate applicationDelegate, ExceptionDelegate arithmeticDelegate, E 
xceptionDelegate divideByZeroDelegate, ExceptionDelegate indexOutOfRangeDelegate 
, ExceptionDelegate invalidCastDelegate, ExceptionDelegate invalidOperationDeleg 
ate, ExceptionDelegate ioDelegate, ExceptionDelegate nullReferenceDelegate, Exce 
ptionDelegate outOfMemoryDelegate, ExceptionDelegate overflowDelegate, Exception 
Delegate 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.RegisterAll() 
   at OSGeo.OGR.Ogr.RegisterAll() 
   at TestProj.Main(String[] args) in \user\Downloads\Workspace\TestProj\project.cs:line 47


and also the following log info: 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities\14.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.dll'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities.Sync\14.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.Sync.dll'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.Debugger.Runtime\14.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Debugger.Runtime.dll'.
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded '\user\Downloads\Gdal_folder\TestProj\bin\Debug\TestProj.vshost.exe'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml.Linq\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.Linq.dll'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Data.DataSetExtensions\v4.0_4.0.0.0__b77a5c561934e089\System.Data.DataSetExtensions.dll'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Microsoft.CSharp\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.CSharp.dll'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_64\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Net.Http\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Net.Http.dll'. Cannot find or open the PDB file. 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll'. Cannot find or open the PDB file. 
The thread 0x2228 has exited with code 0 (0x0). 
The thread 0x1b30 has exited with code 0 (0x0). 
The thread 0x2a64 has exited with code 0 (0x0). 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded '\user\Downloads\Gdal_folder\TestProj\bin\Debug\TestProj.exe'. Symbols loaded. 
The thread 0x2c20 has exited with code 0 (0x0). 
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded '\user\Downloads\Gdal_folder\TestProj\bin\Debug\ogr_csharp.dll'. Module was built without symbols. 
Exception thrown: 'System.DllNotFoundException' in ogr_csharp.dll 
Exception thrown: 'System.TypeInitializationException' in ogr_csharp.dll 
Exception thrown: 'System.TypeInitializationException' in ogr_csharp.dll 
An unhandled exception of type 'System.TypeInitializationException' occurred in ogr_csharp.dll 
Additional information: The type initializer for 'OSGeo.OGR.OgrPINVOKE' threw an exception. 

The program '[2244] TestProj.vshost.exe' has exited with code 0 (0x0)

_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev



_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Loading...