阅读:1019回复:0
C#开发8。3时候的问题
<P>下边是我写的一个小程序,怎么也运行不了,生成后用regasm addlayer.dll来注册也显示成功,不知道为什么就添加不到AO里边,很久了一直想不出办法,只好到论坛上来找各位高人求助</P>
<P>using System; using System.Runtime.InteropServices; using ESRI.ArcObjects.Core; using System.Drawing;</P> <P>namespace addlayer { /// <summary> /// createAddLayerMenu 的摘要说明。 /// </summary> /// [ClassInterface(ClassInterfaceType.None)]</P> <P> [Guid("481D302A-A59A-494c-B1A3-258F6B36E8EF")]</P> <P> public class createAddLayerMenu:IRootLevelMenu,IMenuDef {</P> <P> #region Component Category Registration</P> <P> [ComRegisterFunction]</P> <P> [ComVisible(false)]</P> <P> public static void RegisterFunction(Type t)</P> <P> {</P> <P> string sKey = @"\CLSID\{" + t.GUID.ToString() + @"}\Implemented Categories";</P> <P> Microsoft.Win32.RegistryKey regKey = Microsoft.Win32.Registry.ClassesRoot .OpenSubKey(sKey, true);</P> <P> if (regKey != null)</P> <P> {</P> <P> regKey.CreateSubKey("{481D302A-A59A-494c-B1A3-258F6B36E8EF}");</P> <P> }</P> <P> }</P> <P> </P> <P> [ComUnregisterFunction]</P> <P> [ComVisible(false)]</P> <P> public static void UnregisterFunction(Type t)</P> <P> {</P> <P> string sKey = @"\CLSID\{" + t.GUID.ToString() + @"}\Implemented Categories";</P> <P> Microsoft.Win32.RegistryKey regKey = Microsoft.Win32.Registry.ClassesRoot .OpenSubKey(sKey, true);</P> <P> if (regKey != null)</P> <P> {</P> <P> regKey.DeleteSubKey("{481D302A-A59A-494c-B1A3-258F6B36E8EF}");</P> <P> }</P> <P> }</P> <P> #endregion</P> <P> public createAddLayerMenu() { // // TOD 在此处添加构造函数逻辑 //</P> <P> }</P> <P> #region IMenuDef 成员</P> <P> public void GetItemInfo(int pos, IItemDef itemDef) { // TOD 添加 createAddLayerMenu.GetItemInfo 实现 switch(pos) { case 0 : itemDef.ID = "addlayer.addAllLayer"; itemDef.Group = false; break; case 1 : itemDef.ID = "addlayer.addChangeConstruction"; itemDef.Group = true; break; case 2 : itemDef.ID = "addlayer.addCurPlan"; itemDef.Group = false; break; case 3 : itemDef.ID = "addlayer.addExecuteConstruction"; itemDef.Group = true; break; case 4 : itemDef.ID = "addlayer.addOriginalConstruction"; itemDef.Group = false; break; case 5 : itemDef.ID = "addlayer.addSmallField"; itemDef.Group = true; break; //case 6 : itemDef.ID = "addlayer.clearAllLayers"; //itemDef.Group = true; } }</P> <P> public string Caption { get { // TOD 添加 createAddLayerMenu.Caption getter 实现 return "AddLayer"; } }</P> <P> public string Name { get { // TOD 添加 createAddLayerMenu.Name getter 实现 return "AddLayer"; } }</P> <P> public int ItemCount { get { // TOD 添加 createAddLayerMenu.ItemCount getter 实现 return 6; } }</P> <P> #endregion } } </P> |
|