[mapguide-users] GetClassDefinition of MgLayerBase Error
Markus Roth
m.roth at gds-team.de
Wed Aug 3 10:39:21 EDT 2011
Hi all,
I want to display all PropertyNames of one layer on a new website without displaying the Map. The problem is to read the classDefinition of one layer. The SiteConnection works fine and I can read all the LayerNames of the Map. But when I try to get the ClassDefinition of the layers (Dim MyMGClassDef = MyMGLayerCollection.Item(iL).GetClassDefinition()) it always get an error in Source OSGeo.MapGuide.MapGuideCommon -> MgNullReferenceException
How can I solve this problem?
Here is my code:
MapGuideApi.MgInitializeWebTier(Server.MapPath("~/config/webconfig.ini"))
Dim MyMGUserInfo As New MgUserInformation()
MyMGUserInfo.SetMgUsernamePassword("Anonymous","")
Dim MyMGSiteConnection As New MgSiteConnection()
MyMGSiteConnection.Open(MyMGUserInfo)
Dim RS As MgResourceService = MyMGSiteConnection.CreateService(MgServiceType.ResourceService)
Dim RI As MgResourceIdentifier = New MgResourceIdentifier("StringWeblayout...")
Dim MyMGWebLayout As MgWebLayout = New MgWebLayout(RS, RI)
Dim MyMapNameStr As String = "MapName..."
Dim RSm As MgResourceService = MyMGSiteConnection.CreateService(MgServiceType.ResourceService)
Dim RIm As MgResourceIdentifier = New MgResourceIdentifier(MyMGWebLayout.GetMapDefinition)
Dim MyMGMap As New MgMap()
MyMGMap.Create(RSm, RIm, MyMapNameStr)
Dim MyMGLayerCollection = MyMGMap.GetLayers
For iL As Integer = 0 To MyMGLayerCollection.Count - 1
Dim LName As String = MyMGLayerCollection.Item(iL).GetLayerDefinition.GetName
If LName = "LayerName..." Then
Dim MyMGClassDef = MyMGLayerCollection.Item(iL).GetClassDefinition()
For i As Integer = 0 To MyMGClassDef.GetProperties.Count 1
....
Markus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapguide-users/attachments/20110803/009f2564/attachment.html
More information about the mapguide-users
mailing list