MapScript C# (MapServer 4.10): mapscriptPINVOKE problem on 64-bit platform.

Tamas Szekeres szekerest at GMAIL.COM
Thu Jan 25 14:37:26 EST 2007


Hi,

You probably need to link against the 64 bit version of the
MSVCR80.DLL in this case.
The Visual Studio 8 Dependency Walker can display the 64 bit images as well.

In order to produce 64 bit code you should set the proper environment
variables for your command prompt first. In your case opening the
'Visual Studio 2005 x64 Win64 Command  Prompt' would be sufficient.
Alternatively you can look into C:\Program Files (x86)\Microsoft
Visual Studio 8\VC\vcvarsall.bat and find out a proper path to your
specific vcvars....bat to run.
Apparently, to execute your 64 bit code the dependent dll-s (eg.
proj.dll) might also be compiled as a 64 bit image.

<mapscript C# specific>

You should make sure your code is running against the proper version
of the .NET framework. For example you can use the SysInternals
Filemon to check whether the 64 bit or the 32 bit version has been
loaded. Sometimes, you might want to force the usage of a specific
framework by adding supportedRuntime to the app.config file, like:

<configuration>
<startup>
  <supportedRuntime version="v2.0.50727" />
</startup>
</configuration>

If you compile code to produce a Win32 image on a Win64 platform (By
using the Visual Studio 2005 Command Prompt for example) the default
options does not force to use the 32 bit version of the framework, and
your application will not run properly. Therefore you might want to
add '/platform:x86' to your csc command line when compiling the
mapscript libraries in this case. (the default option is
/platform:any)

<end mapscript C# specific>

In the future, I consider adding some further action to the csharp's
makefile.vc in order to handle these cases more smoothly.

Best Regards,

Tamas



2007/1/25, Hong <ljfong at sdf.lonestar.org>:
> Yep I know I need 64-bit DLLs. The MapServer I used was compiled from the
> source (buildkit) with very stripped down configurations, that was, no linkage
> to MySQL, PDF generation library, GEOS, and others, as they were irrelevant to
> what I needed.
>
> Looking at all the switches for cl.exe (visual c++ compiler), link.exe (visual
> c++ linker), and csc.exe (c# compiler), I did not notice any specific switch
> to produce 64-bit code. Since I compiled it using Visual Studio 2005 installed
> and running on a 64-bit machine, I think the code produced should run on a
> 64-bit machine. Apparently it is just not that simple. I'm starting to think
> it was either incorrect CRT library being loaded or the SWIG binary I used to
> produce the c# mapscript binding DLLs was not 64-bit. I'm still at loss
> however.
>
> Nope, I doubt it would make a difference to have AMD processor, after all AMD
> architecture is virtually the same as Intel one, as far as assembly
> instructions go. Unless the software has to interact with the processor
> directly and make use of processor specific assembly instructions in some way,
> which I don't think applies to MapServer, it should not matter.
>
> Hong.
>
> On Thu, Jan 25, 2007 at 10:34:21AM +0100, Tobias.Knoetzele at atosorigin.com wrote:
> > Hi,
> >
> > I don?t know much about C and the very special Error you had.
> > But I know that
> > - there are dependencies between the DLLs
> > - you need 64-Bit DLLs
> > - I didn?t manage to get the DLLs required as 64 Bit - one isn?t Open Source and the producer says it?s not available for 64Bit Windows.
> >
> > Maybe this helps you.
> >
> > If you say you?ve got all the DLLs as 64 Bit - then I?d love to have them. Do you know wether it makes a difference to have AMD Processors?
> >
> > These are the DLLs required:
> > ssleay32.dll
> > xerces-c_2_7.dll
> > zlib1.dll
> > bgd.dll
> > gdal13.dll
> > geos_c.dll
> > geotiff.dll
> > iconv.dll
> > libcurl.dll
> > libeay32.dll
> > libecwj2.dll
> > libmap.dll
> > libmysql.dll
> > libpq.dll
> > libtiff.dll
> > libxml2.dll
> > lti_dsdk_dll.dll
> > mapscript.dll
> > pdflib.dll
> > proj.dll
> >
> > Tobias
> >
> > -----Urspr?ngliche Nachricht-----
> > Von: UMN MapServer Users List [mailto:MAPSERVER-USERS at lists.umn.edu] Im Auftrag von Hong
> > Gesendet: Donnerstag, 25. Januar 2007 01:49
> > An: MAPSERVER-USERS at lists.umn.edu
> > Betreff: [UMN_MAPSERVER-USERS] MapScript C# (MapServer 4.10): mapscriptPINVOKE problem on 64-bit platform.
> >
> > Hi,
> >
> > I was trying to run mapserver compiled on a 64-bit Intel dual xeon processor machine running Windows Server 2003 R2 64-bit edition. On map object creation, the subroutine threw an exception "The type initializer for 'mapscriptPINVOKE'
> > threw an exception.". The stack trace was:
> >
> > at mapscriptPINVOKE.new_mapObj(String jarg1) at mapObj..ctor(String filename)
> >
> > I wrote a small test C++ application on the 64-bit machine that tried to create a map object by compiling and linking it to mapscript.lib and mapscript_i.lib. The application ended up with the error:
> >
> > Debug Assertion Failed!
> > Program: D:\TGI\Developer\MapServerTest\debug\MapServerTest.exe
> > File: dbgheap.c
> > Line: 1252
> >
> > Expression: _CrtIsValidHeapPointer(pUserData)
> >
> > So it looked like I was having problem with the CRT library on the 64-bit machine. Looking at libmap.dll revealed that it depended on c:\windows\syswow64\MSVCRT.DLL (is this the correct CRT to load?)
> >
> > The compiler was MS Visual Studio 2005.
> >
> > The C++ test program itself:
> >
> > // MapServerTest.cpp : Defines the entry point for the console application.
> > //
> >
> > #include "stdafx.h"
> > #include <iostream>
> > #include "map.h"
> >
> >
> > int _tmain(int argc, _TCHAR* argv[])
> > {
> >       std::cout << "Hello World" << std::endl;
> >
> >       mapObj* p_mapObj = msNewMapObj();
> >
> >       return 0;
> > }
> >
> > At this point I'm stumped on where to proceed next and can use any help/suggestion.
> >
> > Hong
> >
>



More information about the mapserver-users mailing list