c#编译错误Inconsistent accessibility

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/cctt_1/article/details/1756147

原因:一个类A使用了另一个类B的对象。但是类B的类型不是public,也不是内部类。

于是引发此编译错误 

Inconsistent accessibility: parameter type xxx is less accessible than method x

10-27

完整的代码:[code=csharp]using System;rnusing System.Drawing;rnusing System.Runtime.InteropServices;rnusing ESRI.ArcGIS.ADF.BaseClasses;rnusing ESRI.ArcGIS.ADF.CATIDs;rnusing ESRI.ArcGIS.Controls;rnrnnamespace Engine.App_Code rn /// rn /// Summary description for OpenMxdCommand.rn /// rn [Guid("ce02d34f-135a-42f5-9955-80402160acf9")]rn [ClassInterface(ClassInterfaceType.None)]rn [ProgId("Engine.App_Code.OpenMxdCommand")]rn public sealed class OpenMxdCommand : BaseCommand rn #region COM Registration Function(s)rn [ComRegisterFunction()]rn [ComVisible(false)]rn static void RegisterFunction(Type registerType) rn // Required for ArcGIS Component Category Registrar supportrn ArcGISCategoryRegistration(registerType);rnrn //rn // TODO: Add any COM registration code herern //rn rnrn [ComUnregisterFunction()]rn [ComVisible(false)]rn static void UnregisterFunction(Type registerType) rn // Required for ArcGIS Component Category Registrar supportrn ArcGISCategoryUnregistration(registerType);rnrn //rn // TODO: Add any COM unregistration code herern //rn rnrn #region ArcGIS Component Category Registrar generated codern /// rn /// Required method for ArcGIS Component Category registration -rn /// Do not modify the contents of this method with the code editor.rn /// rn private static void ArcGISCategoryRegistration(Type registerType) rn string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\0", registerType.GUID);rn ControlsCommands.Register(regKey);rnrn rn /// rn /// Required method for ArcGIS Component Category unregistration -rn /// Do not modify the contents of this method with the code editor.rn /// rn private static void ArcGISCategoryUnregistration(Type registerType) rn string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\0", registerType.GUID);rn ControlsCommands.Unregister(regKey);rnrn rnrn #endregionrn #endregionrnrn private IHookHelper m_hookHelper;rn private IMapControl3 mapCtrl = null;rnrn private ControlsSynchronizer m_controlsSynchronizer;rnrn public OpenMxdCommand() rn base.m_category = "打开地图文档"; //localizable textrn base.m_caption = "打开地图文档"; //localizable textrn base.m_message = "打开地图文档"; //localizable text rn base.m_toolTip = "打开地图文档"; //localizable text rn base.m_name = "打开地图文档"; //unique id, non-localizable (e.g. "MyCategory_MyCommand")rnrn try rn string bitmapResourceName = GetType().Name + ".bmp";rn base.m_bitmap = new Bitmap(GetType(), bitmapResourceName);rn rn catch (Exception ex) rn System.Diagnostics.Trace.WriteLine(ex.Message, "Invalid Bitmap");rn rn rnrn public OpenMxdCommand(ControlsSynchronizer controlsSynchronizer)rn : this() rn m_controlsSynchronizer = controlsSynchronizer;rn rnrn #region Overridden Class Methodsrnrn /// rn /// Occurs when this command is createdrn /// rn /// Instance of the applicationrn public override void OnCreate(object hook) rn if (hook == null)rn return;rnrn if (m_hookHelper == null)rn m_hookHelper = new HookHelperClass();rnrnrn m_hookHelper.Hook = hook;rnrn if (hook is IToolbarControl) rn IToolbarControl tbarCtrl = (IToolbarControl)hook;rn mapCtrl = (IMapControl3)tbarCtrl.Buddy;rn rn else if (hook is IMapControl3)rn mapCtrl = (IMapControl3)hook;rn rnrn /// rn /// Occurs when this command is clickedrn /// rn public override void OnClick() rn System.Windows.Forms.OpenFileDialog openMxdDlg = new System.Windows.Forms.OpenFileDialog();rn openMxdDlg.Filter = "Map Document(*.mxd)|*.mxd";rn openMxdDlg.Multiselect = false;rn openMxdDlg.Title = "Open map document";rn if (openMxdDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) rn string fileName = openMxdDlg.FileName;rn ESRI.ArcGIS.Carto.IMapDocument mDoc = new ESRI.ArcGIS.Carto.MapDocumentClass();rn //权限验证.rn if (mDoc.get_IsPresent(fileName) && !mDoc.get_IsPasswordProtected(fileName)) rn //mapCtrl.LoadMxFile(fileName);rn //mapCtrl.Extent = mapCtrl.FullExtent; //全幅.rn //mapCtrl.ActiveView.Refresh();rnrn mDoc.Open(fileName);rn ESRI.ArcGIS.Carto.IMap map = mDoc.get_Map(0);rn mDoc.SetActiveView((ESRI.ArcGIS.Carto.IActiveView)map);rn controlsSynchronizer.PageLayoutControl.PageLayout = mDoc.PageLayout;rn controlsSynchronizer.ReplaceMap(map);rn mDoc.Close(); //?.rn rn rn rnrn #endregionrn rnrn[/code]rnrn请问是哪里错了... 论坛

没有更多推荐了,返回首页