diff --git a/HISTORY.TXT b/HISTORY.TXT index fcd68d34c8..2d7851f8cd 100644 --- a/HISTORY.TXT +++ b/HISTORY.TXT @@ -13,6 +13,8 @@ For a complete change history, please see the Subversion log comments. Current Version: ---------------- +- Ensure the class is not marked BeforeFieldInit causing memory corruption with C#/CLR4 (#3438) + - Fixed MSSQL2008 driver returning invalid extent (#3498) - Backport the recent fixes in the MSSQL2008 driver (#3058, #3244) diff --git a/mapscript/csharp/Makefile.vc b/mapscript/csharp/Makefile.vc index 99911b6651..4499eac815 100755 --- a/mapscript/csharp/Makefile.vc +++ b/mapscript/csharp/Makefile.vc @@ -48,7 +48,7 @@ CSC = csc $(CSDEBUG) !ENDIF !IF $(MSVC_VER) >= 1600 -CSC = $(CSC) /define:CLR4 /debug:full +CSC = $(CSC) /define:CLR4 !ENDIF #SWIG = swig diff --git a/mapscript/csharp/swig_csharp_extensions.i b/mapscript/csharp/swig_csharp_extensions.i index 54c9f99255..1d6e84be97 100644 --- a/mapscript/csharp/swig_csharp_extensions.i +++ b/mapscript/csharp/swig_csharp_extensions.i @@ -29,6 +29,12 @@ * DEALINGS IN THE SOFTWARE. *****************************************************************************/ +// Ensure the class is not marked BeforeFieldInit causing memory corruption with CLR4 +%pragma(csharp) imclasscode=%{ + static $imclassname() { + } +%} + %typemap(csout, excode=SWIGEXCODE) SWIGTYPE { $&csclassname ret = new $&csclassname($imcall, true, null);$excode return ret;