Creating .NET objects for Mapguide Enterprise 2011

Better late than never…  I’ve updated my Mapguide Enterprise .NET objects to work with 2011.  The steps in my   have been modernized and simplified significantly.   This post will show you how to create (or re-create) these objects for the 2011 release of Mapguide.  Sorry for skipping 2010 =)

First, download the actual non-aplha release of and extract it.  You will need to have .NET 3.5 installed to run LINQ to XSD.  The project itself is a Visual Studio 2010, .NET 4.0 project.  You should be able to change it to .NET 3.5 with no problems.  I’m not sure about using .NET 2.0.   I still assume these steps should work with Mapguide Open Source 2.2 given its pretty much the same thing as MGE 2011.  Please let me know if you try it and that is not the case.

Building the classes

Last time around we had to mess around with Visual Studio projects, building temporary code, finding and extracting that code from temporary files.  This time around, we’re given a nice little executable that can be run in a batch file.   I’ve posted a copy of my batch file below but it was simply made using a dir /b > CreateMapguideNetObjects.cmd in the Mapguide server schema folder (which by default is to c:\Program Files\Autodesk\MapGuideEnterprise2011\Server\Schema) .  I then edited that file with a text editor that support macros and removed the following schema files:

  • FdoProviderCapabilities-1.0.0.xsd
  • LoadProcedure-1.0.0.xsd
  • LoadProcedure-1.1.0.xsd
  • LayerDefinition-1.0.0.xsd
  • LayerDefinition-1.1.0.xsd
  • LayerDefinition-1.2.0.xsd
  • SiteInformation-1.0.0.xsd
  • SiteVersion-1.0.0.xsd
  • SymbolDefinition-1.0.0.xsd
  • WebLayout-1.0.0.xsd

These files are deprecated object definitions from previous Mapguide releases.  In the end each line in the batch file looks a little like this:

LinqToXsd ApplicationDefinition-1.0.0.xsd /filename:ApplicationDefinition.cs

Executing the batch file will create a number of C# files containing appropriately named classes.

Setting up your project

At this point you should be able to fire up Visual Studio and create a new C# project.   If you have an existing project from a previous version of Mapguide its good to start fresh.  Also, don’t try this in an existing solution that is dependant on the project that contains the Mapguide objects.  This will just result in a bunch of extra screwing around to avoid compiler errors from missing code during the process.    This time around its a lot easier.  Create a new DLL project.  Add a reference to the Xml.Schema.Linq.dll file that was included with LinqToXsd.exe.   Add a reference to the following Mapguide dlls:

  • OSGeo.Mapguide.Foundation
  • OSGeo.Mapguide.Geometry
  • OSGeo.Mapguide.MapguideCommon
  • OSGeo.Mapguide.PlatformBase
  • OSGeo.Mapguide.Web

You’ll also need to ensure that the appropriate unmanaged assemblies are available in the calling applications bin folder when you go to run this stuff. 

Next place all of the generated C# files in the new project.  Once you build you’re going to see a ton of errors.  We’ll clean those up.

To resolve a lot of these errors I did a global search and replace on “global::” and replaced it with nothing.  Also, I wrapped each class in a unique wrapper classes to prevent duplicate type errors.  Finally, the case issue with DataType was still an issue – and I resolved it by changing the case on DataType to be Datatype:

Page 1 of 3 | Next page