[gdal-dev] Issue with c# bindings
I'm getting this error after compiling from source Exception thrown: 'System.MethodAccessException' in gdal_csharp.dll Additional information: Attempt by security transparent method 'OSGeo.GDAL.Gdal.UseExceptions()' to call native code through method 'OSGeo.GDAL.GdalPINVOKE.UseExceptions()' failed. Methods must be security critical or security safe-critical to call native code. I did nmake -f makefile.vc clean && nmake -f makefile.vc MSVC_VER=1600 DEBUG=1 && nmake -f makefile.vc install cd swig nmake -f makefile.vc csharp I get the gdal dll + the csharp dlls...and I use them But as soon as I call OSGeo.GDAL.Gdal.UseExceptions(); I get the exception This doesn't happen with the dll's I've downloaded from http://www.gisinternals.com/ I got the source from https://trac.osgeo.org/gdal/wiki/DownloadSource and I got 2.0.1 ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] Issue with c# bindings
Hi Kelly, It looks like you are compiling against .Net 4 and the /define:CLR4 is missing from the csc command line. Also make sure the following line is added to AssemblyInfo.cs when compiling the assemblies: [assembly: SecurityRules(SecurityRuleSet.Level1)] Best regards, Tamas 2015-12-09 23:02 GMT+01:00 kelly elton: > I'm getting this error after compiling from source > > Exception thrown: 'System.MethodAccessException' in gdal_csharp.dll > > Additional information: Attempt by security transparent method > 'OSGeo.GDAL.Gdal.UseExceptions()' to call native code through method > 'OSGeo.GDAL.GdalPINVOKE.UseExceptions()' failed. Methods must be security > critical or security safe-critical to call native code. > > I did > nmake -f makefile.vc clean && nmake -f makefile.vc MSVC_VER=1600 DEBUG=1 > && nmake -f makefile.vc install > cd swig > nmake -f makefile.vc csharp > > I get the gdal dll + the csharp dlls...and I use them > > But as soon as I call OSGeo.GDAL.Gdal.UseExceptions(); I get the exception > > This doesn't happen with the dll's I've downloaded from > http://www.gisinternals.com/ > > I got the source from https://trac.osgeo.org/gdal/wiki/DownloadSource and > I got 2.0.1 > > ___ > gdal-dev mailing list > gdal-dev@lists.osgeo.org > http://lists.osgeo.org/mailman/listinfo/gdal-dev > ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] Issue with c# bindings
Alright well I figure that out...Targeted a specific MSVC_VER in csharp.opt On Wed, Dec 9, 2015 at 5:02 PM kelly eltonwrote: > I'm getting this error after compiling from source > > Exception thrown: 'System.MethodAccessException' in gdal_csharp.dll > > Additional information: Attempt by security transparent method > 'OSGeo.GDAL.Gdal.UseExceptions()' to call native code through method > 'OSGeo.GDAL.GdalPINVOKE.UseExceptions()' failed. Methods must be security > critical or security safe-critical to call native code. > > I did > nmake -f makefile.vc clean && nmake -f makefile.vc MSVC_VER=1600 DEBUG=1 > && nmake -f makefile.vc install > cd swig > nmake -f makefile.vc csharp > > I get the gdal dll + the csharp dlls...and I use them > > But as soon as I call OSGeo.GDAL.Gdal.UseExceptions(); I get the exception > > This doesn't happen with the dll's I've downloaded from > http://www.gisinternals.com/ > > I got the source from https://trac.osgeo.org/gdal/wiki/DownloadSource and > I got 2.0.1 > ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev