Access from .Net winforms or console?

Jason Birch Jason.Birch at nanaimo.ca
Fri May 19 18:22:43 EDT 2006


I'm playing around with using MapGuide within Visual Studio/C# and am
getting stuck pretty early.

I have added a reference to MapGuideDotNetAPI (the dll is in the bin
directory) and imported the OSGeo.MapGuide namespace.  Intellisense
seems to be working correctly, and the app seems to compile OK. However,
on the first call to a MapGuide method, I get an exception.

"The type initializer for 'MapGuideApiPINVOKE' threw an exception."

Anyone have any ideas?  I'm a bit of a newbie in this environemnt, so
feel free to whack me on the side of the head :)

Jason

Oh, here's the code:

using System;
using System.IO;
using System.Collections.Generic;
using System.Text;
using OSGeo.MapGuide;


namespace cli_makepackage
{
    class Program
    {
        
        static void Main(string[] args)
        {
            try
            {

                MapGuideApi.MgInitializeWebTier("./webconfig.ini");
                MapGuideApi.InitializeSockets();
                MgUserInformation userInfo = new
MgUserInformation("Administrator", "admin");
                MgSite mgSite = new MgSite();
                mgSite.Open(userInfo);

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }


            
        }
    }
}





More information about the Mapguide-users mailing list