is inaccessible due to its protection level

Cory Gregor cgregor at barkerlemar.com
Tue Oct 10 13:15:13 EDT 2006


Thank You Andy  that fixed that problem.

Can you help me with this problem?  It is telling me that the Line
map.Open(ResouceService, realMapName); is telling me that " ResourceService"
does not exist in the current context.

There is most of my code....


    String mapDefinition =
"Library://Samples/FredWeber/Maps/Default.MapDefinition";
    String webLayout = "Library://Samples/FredWeber/FredWeber.WebLayout";
    String sessionId = "";
    String NoLayers = "No Layers Selected";
    
    try
    {
        MapGuideApi.InitializeSockets();
        
        string realPath = Request.ServerVariables["APPL_PHYSICAL_PATH"];
        String configPath = realPath + "webconfig.ini";
        MapGuideApi.MgInitializeWebTier(configPath);


        MgUserInformation userInfo = new MgUserInformation("Administrator",
"admin");
        MgSite site = new MgSite();

        site.Open(userInfo);
        sessionId = site.CreateSession();

        MgSiteConnection siteConnection = new MgSiteConnection();
        siteConnection.Open(userInfo);

        MgResourceService ResourceService =
siteConnection.CreateService(MgServiceType.ResourceService) as
MgResourceService;
        MgFeatureService FeatureService =
siteConnection.CreateService(MgServiceType.FeatureService) as
MgFeatureService; 
        MgFeatureQueryOptions QueryOptions = new MgFeatureQueryOptions();

        //string realMapName = Request.ServerVariables["mapName"];
        MgMap map = new MgMap(mapDefinition);
        map.Open(ResouceService, realMapName);
        MgSelection selection = new MgSelection(map);
        selection.Open(ResouceService, "map");

        MgLayer Layers = new MgLayerCollection(map);

        if (Layers)
        {
            for (i = 0; i < Layers.GetCount(); i++)
            {

                //Only check selected features in the Parcels layer.

                Layers = Layers.GetLayerType(i);

                if (Layers && Layers.GetLayerDefinition() == "Default_Map
Base_727(3)")
                {
                    //Create a filter containing the IDs of the selected 
                    //features on this layer

                    LayerClassName = Layer.GetFeatureClassName();
                    selectionString = selection.GenerateFilter(Layer,
LayerClassName);

                    //Get the feature resource for the selected layer

                    LayerFeatureId = Layer.GetFeatureSourceId();
                    LayerFeatureResource = new
MgResourceIdentifier(LayerFeatureId);

                    //Apply the filter to the feature resource for the 
                    // selected layer. This returns


                    //an MgFeatureReader of all the selected features.

                    QueryOptions.SetFilter(selectionString);

                    FeatureReader =
FeatureService.SelectFeatures(LayerFeatureResource, LayerClassName,
QueryOptions);

                    //Process each item in the MgFeatureReader, displaying
the 
                    //owner name and address

                    while (FeatureReader.ReadNext())
                    {

                        val = FeatureReader.GetString("FeatureID");

                        //FeatureReader.GetString("Layer");

                        echo val;

                    }

                }

            }

        }

        else
        {
            echo NoLayers;
        }    
            
            
        MapGuideApi.TerminateSockets();
    }
    catch (MgException mge)
    {
        Response.Write(mge.GetMessage());
        Response.Write(mge.GetDetails());
        MapGuideApi.TerminateSockets();
    }

If there is any think that is not correct please let me know.
Thanks, 
Cory



Andy Morsell wrote:
> 
> Try this instead (the email will probably wrap the lines);
> 
> MgResourceService ResourceService =
> siteConnection.CreateService(MgServiceType.ResourceService) as
> MgResourceService;			
> 
> MgFeatureService FeatureService =
> siteConnection.CreateService(MgServiceType.FeatureService) as
> MgFeatureService; 
> 
> 
> Andy Morsell, P.E.
> Spatial Integrators, Inc.
> http://www.SpatialGIS.com
> 
> -----Original Message-----
> From: Cory Gregor [mailto:cgregor at barkerlemar.com] 
> Sent: Tuesday, October 10, 2006 6:58 AM
> To: users at mapguide.osgeo.org
> Subject: [mapguide-users] is inaccessible due to its protection level
> 
> 
> OK, first of all i am new at the whole MGOS and C#.   I gotten maps to
> show
> up fine. So i am guessing that my server is configured correct.  i am
> running IIS 6 on Win 2k3 server.   I am using Visual Studio 2005. 
> 
> I keep getting this error and can not find any help if it. 
> 
> Compiler Error Message: CS0122:
> 'OSGeo.MapGuide.MgResourceService.MgResourceService()' is inaccessible due
> to its protection level
> 
> Source Error:
> 
>  
> 
> Line 47:         MgMap Map = new MgMap();
> Line 48: 
> Line 49:         MgResourceService ResouceService = new
> MgResourceService();
> Line 50:         MgFeatureService FeatureService = new MgFeatureService();
> Line 51:         MgFeatureQueryOptions QueryOptions = new
> MgFeatureQueryOptions();
>  
> Am i using the it Wrong?   
> The goal is to get the Layer Name and the ID  from the layer and pass it
> to
> another page.
> Please help if you can.  I am pass a deadline of this.
> 
> Thanks,
> Cory
> --
> View this message in context:
> http://www.nabble.com/is-inaccessible-due-to-its-protection-level-tf2416853.
> html#a6737010
> Sent from the OSGeo MapGuide mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe at mapguide.osgeo.org
> For additional commands, e-mail: users-help at mapguide.osgeo.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe at mapguide.osgeo.org
> For additional commands, e-mail: users-help at mapguide.osgeo.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/is-inaccessible-due-to-its-protection-level-tf2416853.html#a6741102
Sent from the OSGeo MapGuide mailing list archive at Nabble.com.





More information about the Mapguide-users mailing list