[mapguide-internals] Managed MGOS API issues

Maksim Sestic max at geoinova.com
Sat Apr 10 05:27:29 EDT 2010


Hi all,

I didn't really follow recent MG OS developments, but there is something
I've tried few days ago and it just didn't work. Namely, the idea was to
utilize managed MG API directly via MapGuideDotNetApi.dll. BTW, this has
nothing to do with MG web tier. So I've coded down a simple Test.dll using
VB.NET which does following:

        ...
        Dim gf As New OSGeo.MapGuide.MgGeometryFactory
        Dim c As OSGeo.MapGuide.MgCoordinate =
gf.CreateCoordinateXYZM(6437556.63, 4966679.98, 0, 0)
        ...

Nothing spectacular, indeed :-) Now, there's also another Text.exe calling
above dll, so I could test whether API call really works. Target binary
folder (containing my Test.exe and Test.dll binaries) also contains
following files:

MapGuideDotNetApi.dll
ACE.dll
GEOS.dll
lib_json.dll
MapGuideUnmanagedApi.dll
MgFoundation.dll
MgGeometry.dll
MgHttpHandler.dll
MgMapGuideCommon.dll
MgMdfModel.dll
MgMdfParser.dll
MgPlatformBase.dll
MgWebApp.dll
xerces-c_2_7.dll

...which is about every reference being made out of
MapGuideUnmanagedApi.dll.

Now, when I run Test.exe - everything works just fine. Text.exe calls my
Test.dll which calls MapGuideDotNetApi.dll wrapper, etc.

But, if I NETLOAD above Test.dll (decorated as an ACAD command) into AutoCAD
Map 3D and try running the same function, following exception gets thrown:

************** Exception Text **************
System.TypeInitializationException: The type initializer for
'OSGeo.MapGuide.MapGuideApiPINVOKE' threw an exception. --->
System.TypeInitializationException: The type initializer for
'SWIGExceptionHelper' threw an exception. ---> System.DllNotFoundException:
Unable to load DLL 'MapGuideUnmanagedApi': The specified procedure could not
be found. (Exception from HRESULT: 0x8007007F)
   at
OSGeo.MapGuide.MapGuideApiPINVOKE.SWIGExceptionHelper.SWIGRegisterCustomExceptionCallbacks_MapGuideApi(SWIGCustomExceptionDelegate
customExceptionDelegate)
   at OSGeo.MapGuide.MapGuideApiPINVOKE.SWIGExceptionHelper..cctor()
   --- End of inner exception stack trace ---
   at OSGeo.MapGuide.MapGuideApiPINVOKE.SWIGExceptionHelper..ctor()
   at OSGeo.MapGuide.MapGuideApiPINVOKE..cctor()
   --- End of inner exception stack trace ---
   at OSGeo.MapGuide.MapGuideApiPINVOKE.new_MgGeometryFactory()
   at OSGeo.MapGuide.MgGeometryFactory..ctor()
...
etc, etc
...

MapGuideDotNetApi.dll performs a simple DllImport:

<DllImport("MapGuideUnmanagedApi",
EntryPoint:="CSharp_new_MgGeometryFactory")> _
Public Shared Function new_MgGeometryFactory() As IntPtr
End Function


I'm quite confused here:

1) When called directly from Test.exe, API call to MapGuideDotNetApi.dll
works OK.
2) When called via NETLOAD-ed dll within AutoCAD Map, MapGuideDotNetApi.dll
can't find MapGuideUnmanagedApi.dll (?!)

I did try couple of tricks, like setting default (working) folder, etc, but
it still refuses to work under Map. Is is up to SWIG-generated wrapper
maybe? For example, GDAL's OGR managed wrapper works just fine in above
setup.

Regards,
Maksim Sestic
-- 
View this message in context: http://n2.nabble.com/Managed-MGOS-API-issues-tp4881375p4881375.html
Sent from the MapGuide Internals mailing list archive at Nabble.com.


More information about the mapguide-internals mailing list