echan
路人甲
路人甲
  • 注册日期2003-08-26
  • 发帖数11
  • QQ
  • 铜币153枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1754回复:3

如何注册、调用C#+ao8.3生成的DLL?(急,已经好几天过去了都没有进展,跪求高手解答)

楼主#
更多 发布于:2004-10-27 09:35
<P>如何注册、调用C#+ao8.3生成的DLL?(急)</P>
<P>我用以下方法:
1.参照示例1编写C#代码
2.参照示例1引用dll,设置生出属性里面一项什么导出到COM为"true"
2.用GuidTool.exe生成相应的GUID和Component Category(Category Name/Category GUID)填写入程序的相应位置和导入注册表的相应位置
3.编译成dll,执行下面命令
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\regasm xyh.dll /tlb /codebase
显示成功注册COM组件</P>
<P>结果:
打开arcgis 8.3的Custom看不到定制的Command以及Category
强制通过add from file加载dll显示"Can't load type library from speciefied file."
强制通过add from file加载tlb显示"No new objects added."
555,怎么办啊?</P>
<P>打开/bin下面的categories.exe看到我定制的category是生成显示,
category里面也显示我定制的Command名称,
但左键点击却显示"File not found:mscoree.dll"
但我的.Net FrameWork是完全没有问题的,
其他的C#程序都可以顺利运行.

为何刚刚arcgis的定制对话框下却显示不出category,而在categoried.exe下面却可以显示呢?
为何显示找不到mscoree.dll这个.Net核心dll明明是存在的啊

各位朋友帮帮忙,我已经被我的第一个C#+AO程序困扰几天了,怎么就这么难产呢,跪求高手解答!</P>
喜欢0 评分0
echan
路人甲
路人甲
  • 注册日期2003-08-26
  • 发帖数11
  • QQ
  • 铜币153枚
  • 威望0点
  • 贡献值0点
  • 银元0个
1楼#
发布于:2004-10-27 09:41
<P>我写第一份初级代码如下(测试用),麻烦高手看看有没有低级错误,但是编译的时候没有发现错误.
我快要急死了!</P><P>using System;
using ESRI.ArcObjects.Core;
using System.Runtime.InteropServices;</P><P>namespace KSCustomTools
{
 /// <summary>
 /// clsCreatePoint 的摘要说明。
 /// </summary>
 
 #region "COM GUIDs"
 [ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)]
 [Guid("06A42040-58A4-467F-98F0-0D9FA475EB52")]
 #endregion</P><P> public class clsCreatePoint:ICommand
 {
  private IApplication m_app;
  private bool m_enabled;</P><P>  #region Component Category Registration
  [ComRegisterFunction]
  [ComVisible(false)]
  public static void RegisterFunction(Type t)
  {
   string sKey = @"\CLSID\{" + t.GUID.ToString() + @"}\Implemented Categories";
   Microsoft.Win32.RegistryKey regKey
    = Microsoft.Win32.Registry.ClassesRoot
    .OpenSubKey(sKey, true);
   if (regKey != null)
   {
    regKey.CreateSubKey("{B8479800-C120-43FE-9E6B-0928D380112F}");
   }
  }</P><P>   </P><P>  [ComUnregisterFunction]
  [ComVisible(false)]
  public static void UnregisterFunction(Type t)
  {
   string sKey = @"\CLSID\{" + t.GUID.ToString() + @"}\Implemented Categories";
   Microsoft.Win32.RegistryKey regKey
    = Microsoft.Win32.Registry.ClassesRoot
    .OpenSubKey(sKey, true);
   if (regKey != null)
   {
    regKey.DeleteSubKey("{B8479800-C120-43FE-9E6B-0928D380112F}");
   }
  }
  #endregion</P><P>
  public clsCreatePoint()
  {
   //
   // TOD 在此处添加构造函数逻辑
   //
  }
  #region ICommand 成员</P><P>  public void OnClick()
  {
            
  }</P><P>  public string Message
  {
   get
   {
    // TOD  添加 clsCreatePoint.Message getter 实现
    return null;
   }
  }</P><P>  public int Bitmap
  {
   get
   {
    // TOD  添加 clsCreatePoint.Bitmap getter 实现
    return 0;
   }
  }</P><P>  public void OnCreate(object hook)
  {
   if (hook != null)
   {
    if (hook is IMxApplication)
    {
     m_app = (IApplication) hook;
     m_enabled = true;
    }
   }
  }</P><P>  public string Caption
  {
   get
   {
    return "创建界址点";
   }
  }</P><P>  public string Tooltip
  {
   get
   {
    // TOD  添加 clsCreatePoint.Tooltip getter 实现
    return null;
   }
  }</P><P>  public int HelpContextID
  {
   get
   {
    // TOD  添加 clsCreatePoint.HelpContextID getter 实现
    return 0;
   }
  }</P><P>  public string Name
  {
   get
   {
    // TOD  添加 clsCreatePoint.Name getter 实现
    return "CreatePoint";
   }
  }</P><P>  public bool Checked
  {
   get
   {
    // TOD  添加 clsCreatePoint.Checked getter 实现
    return false;
   }
  }</P><P>  public bool Enabled
  {
   get
   {
    // TOD  添加 clsCreatePoint.Enabled getter 实现
    return m_enabled;
   }
  }</P><P>  public string HelpFile
  {
   get
   {
    // TOD  添加 clsCreatePoint.HelpFile getter 实现
    return null;
   }
  }</P><P>  public string Category
  {
   get
   {
    // TOD  添加 clsCreatePoint.Category getter 实现
    return "地籍定制工具";
   }
  }</P><P>  #endregion
 }
}
</P>
举报 回复(0) 喜欢(0)     评分
echan
路人甲
路人甲
  • 注册日期2003-08-26
  • 发帖数11
  • QQ
  • 铜币153枚
  • 威望0点
  • 贡献值0点
  • 银元0个
2楼#
发布于:2004-10-27 19:48
没人顶,我自己顶,只能祈祷
没人顶,我自己顶,只能祈祷
举报 回复(0) 喜欢(0)     评分
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15951
  • QQ
  • 铜币25345枚
  • 威望15368点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
3楼#
发布于:2004-10-27 21:39
<P>应该是dll入口编写的错误</P><P>电脑上没有软件,无法调试</P><P>帮你顶一个</P>
GIS麦田守望者,期待与您交流。
举报 回复(0) 喜欢(0)     评分
游客

返回顶部