AndrewB,

Are you still working on this?   I just ported an app from Windows to C# using 
.net core 2.0 preview 2 and GDAL is working well in that environment.  

--Eric

-----Original Message-----
From: gdal-dev [mailto:gdal-dev-boun...@lists.osgeo.org] On Behalf Of AndrewB
Sent: Friday, June 16, 2017 5:16 AM
To: gdal-dev@lists.osgeo.org
Subject: [gdal-dev] csharp/gdal/fwtools. Problem with migrating from window to 
ubuntu/mono

I'm novice in csharp but i need to migrate csharp project from windows to 
linux(ubuntu)/mono and have problem with this.
I'm using FWTools in C# project under Windows(code below):
including in project 2 dlls and FWTools/Bin in $PATH:
ogr_csharp.dll
osr_csharp.dll

CODE:
using OSGeo.OGR;
using OSGeo.OSR;

private void GenerateMif( ...params... ) {
     Ogr.RegisterAll();
     using (var driver = Ogr.GetDriverByName("MapInfo File") )
            using (var dataSource = driver.CreateDataSource(mifOutputPath,
null) )
            {           
                SpatialReference spatial = GetSpatialByProjection(projection);
                var layer = dataSource.CreateLayer("layer1", spatial, 
wkbGeometryType.wkbUnknown, null);
                CreateLayerFields(result, layer, fieldDefinitionParameters);


and its works.
 

Now i want migrate this functionality to mono/Ubuntu.  
I'm building project in Xamarin Studio from Windows under Mono/.NET platform 

Ogr.RegisterAll();  handles exception in Ubuntu:

The type initializer for 'OSGeo.OGR.Ogr' threw an exception.
The type initializer for 'OSGeo.OGR.OgrPINVOKE' threw an exception.
  at OSGeo.OGR.Ogr..cctor () [0x0000a] in
<beb44ad5c34649f88fca9cbfa4f938ac>:0
  at ExportPerformer.GenerateMif (
Adding FWTools/Bin into PATH didnt help.

Then
I've downloaded and compiled the source for gdal in GNU/Linux. 
I've compiled the swig/csharp bindings. 

Include compiled
gdal_csharp.dll,gdalconst_csharp.dll,ogr_csharp.dll,osr_csharp.dll to Xamarin 
Studio in Windows, build project under Mono/.NET platform, run "mono 
project.exe" from ubuntu and Ogr.RegisterAll(); same DllNotFoundException error:
System.TypeInitializationException: The type initializer for 'OSGeo.OGR.Ogr'
threw an exception. 
---> System.TypeInitializationException: The type initializer for
'OSGeo.OGR.OgrPINVOKE' threw an exception. 
---> System.TypeInitializationException: The type initializer for
'SWIGExceptionHelper' threw an exception. 
---> System.DllNotFoundException: ogrcsharp
  at (wrapper managed-to-native)
OSGeo.OGR.OgrPINVOKE+SWIGExceptionHelper:SWIGRegisterExceptionCallbacks_Ogr
(OSGeo.OGR.OgrPINVOKE/SWIGExceptionHelper/ExceptionDelegate,
OSGeo.OGR.OgrPINVOKE/SWIGExceptionHelper/ExceptionDelegate,
OSGeo.OGR.OgrPINVOKE/SWIGExceptionHelper/ExceptionDelegate,
OSGeo.OGR.OgrPINVOKE/SWIGExceptionHelper/ExceptionDelegate,
OSGeo.OGR.OgrPINVOKE/SWIGExceptionHelper/ExceptionDelegate,
OSGeo.OGR.OgrPINVOKE/SWIGExceptionHelper/ExceptionDelegate,
OSGeo.OGR.OgrPINVOKE/SWIGExceptionHelper/ExceptionDelegate,
OSGeo.OGR.OgrPINVOKE/SWIGExceptionHelper/ExceptionDelegate,
OSGeo.OGR.OgrPINVOKE/SWIGExceptionHelper/ExceptionDelegate,
OSGeo.OGR.OgrPINVOKE/SWIGExceptionHelper/ExceptionDelegate,
OSGeo.OGR.OgrPINVOKE/SWIGExceptionHelper/ExceptionDelegate)
  at OSGeo.OGR.OgrPINVOKE+SWIGExceptionHelper..cctor () [0x000ef] in
<f65c599d29ac40c4b98fd48137f45269>:0    
--- End of inner exception stack trace ---
  at (wrapper managed-to-native)
System.Object:__icall_wrapper_mono_generic_class_init (intptr)
  at OSGeo.OGR.OgrPINVOKE..cctor () [0x00000] in
<f65c599d29ac40c4b98fd48137f45269>:0    
--- End of inner exception stack trace ---
  at OSGeo.OGR.Ogr..cctor () [0x0000a] in
<f65c599d29ac40c4b98fd48137f45269>:0    
--- End of inner exception stack trace ---

What's wrong with that build?


Does that way to migrating from Windows to Linux will works? 
What way(csharp) to migrate this case will be correct?

Thanks.

List of files after compiling swig/csharp under linux 
<http://osgeo-org.1560.x6.nabble.com/file/n5324458/gdalbuild.png> 



--
View this message in context: 
http://osgeo-org.1560.x6.nabble.com/csharp-gdal-fwtools-Problem-with-migrating-from-window-to-ubuntu-mono-tp5324458.html
Sent from the GDAL - Dev mailing list archive at Nabble.com.
_______________________________________________
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev
_______________________________________________
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to