[mapguide-users] Help with Creating map Object...getting MgNullReferenceException

Kenneth, GEOGRAF A/S ks at geograf.dk
Thu May 1 11:01:57 EDT 2008


What do you want to do with the map?
It is unclear to me what the problem is.

Usually some sort of viewer  (Fusion or regular) will create the runtime 
map for you.
You can create a MgUserInformation object with the sessionID.
You can then open the map using "map.Open(...)".

If you want to create a seperate map, you can remove the last two lines.

If you have not already read it, the system is explained in the 
Developers Guide:
http://mapguide.osgeo.org/2.0/documentation.html

Regards, Kenneth, GEOGRAF A/S



Nick Aizen skrev:
>
> Good Day all, I'm new to MapGuide and would appreciate a little 
> assistance in getting over a hump. I'm trying to create a map object 
> so I may query it later in my process. It seems that I'm not creating 
> the map correctly. My code snippet is below and is called when my page 
> loads. Seems as though the map object is not obtaining the sessionID. 
> Can someone advise me as to what I'm doing incorrectly or provide 
> recourses to get me going in the right direction.
>
>  
>
>  
>
> MapGuideApi.MgInitializeWebTier(@"C:\Program 
> Files\Autodesk\MapGuideEnterprise2008\WebServerExtensions\www\webconfig.ini");
>
>     MgUserInformation userInfo = new 
> MgUserInformation("Administrator", "admin");
>
>     MgSite site = new MgSite();
>
>     site.Open(userInfo);
>
>     String sessionId = site.CreateSession();
>
>  
>
>  
>
>     //Associate a session ID with the MgSiteConnection Object
>
>     MgUserInformation userInfo_new = new MgUserInformation(sessionId);
>
>     MgSiteConnection siteConnection = new MgSiteConnection();
>
>     siteConnection.Open(userInfo_new);
>
>     MgResourceService resourceSrvc 
> =(MgResourceService)siteConnection.CreateService(MgServiceType.ResourceService 
> );
>
>     MgMap map = new MgMap(siteConnection);
>
>  
>
>     MgResourceIdentifier resId = new 
> MgResourceIdentifier("Library://Samples/Sheboygan/Maps/Sheboygan.MapDefinition");
>
>     String mapName = resId.GetName();
>
>     map.Create(resourceSrvc, resId,  mapName);
>
>     map.Save(resourceSrvc);
>
>     map.Open(resourceSrvc, mapName);
>
>  
>
>  
>
>  
>
> Many Thanks.
>
>  
>
>  
>
>  
>
>  
>
> *Nick Aizen*
>
> GCR & Associates, Inc.
>
> 2021 Lakeshore Dr., Suite 500
>
> New Orleans, LA 70122
>
> www.gcr1.com
>
> (504) 304-2500 ext. 2320
>
> Fax: (504) 304-2525
>
>  
>
> cid:338554203 at 20092007-3664
>
>  
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> mapguide-users mailing list
> mapguide-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapguide-users
>   
-------------- next part --------------
Skipped content of type multipart/related


More information about the mapguide-users mailing list