<div dir="ltr"><div>Hi Kelly,</div><div><br></div>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:<div><br></div><div>[assembly: SecurityRules(SecurityRuleSet.Level1)]</div><div><br></div><div><br></div><div>Best regards,</div><div><br></div><div>Tamas</div><div><br></div><div><br><div class="gmail_extra"><br><div class="gmail_quote">2015-12-09 23:02 GMT+01:00 kelly elton <span dir="ltr"><<a href="mailto:its.the.doc@gmail.com" target="_blank">its.the.doc@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">I'm getting this error after compiling from source<div><br></div><div><div>Exception thrown: 'System.MethodAccessException' in gdal_csharp.dll</div><div><br></div><div>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.</div></div><div><br></div><div>I did </div><div>nmake -f <a href="http://makefile.vc" target="_blank">makefile.vc</a> clean && nmake -f <a href="http://makefile.vc" target="_blank">makefile.vc</a> MSVC_VER=1600 DEBUG=1 && nmake -f <a href="http://makefile.vc" target="_blank">makefile.vc</a> install<br></div><div>cd swig</div><div>nmake -f <a href="http://makefile.vc" target="_blank">makefile.vc</a> csharp</div><div><br></div><div>I get the gdal dll + the csharp dlls...and I use them</div><div><br></div><div>But as soon as I call OSGeo.GDAL.Gdal.UseExceptions(); I get the exception</div><div><br></div><div>This doesn't happen with the dll's I've downloaded from <a href="http://www.gisinternals.com/" target="_blank">http://www.gisinternals.com/</a></div><div><br></div><div>I got the source from <a href="https://trac.osgeo.org/gdal/wiki/DownloadSource" target="_blank">https://trac.osgeo.org/gdal/wiki/DownloadSource</a> and I got 2.0.1</div></div>
<br>_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" rel="noreferrer" target="_blank">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br></blockquote></div><br></div></div></div>