我不能在C#创建ActiveX控制器,试过很多教程创建ActiveX ..如何在C#
我的步骤: 1.创建类库项目 2.编写代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Text;
using System.Reflection;
using Microsoft.Win32;
using System.Windows.Forms;
namespace AACWCSurvey
{
[ProgId("Prisoner.PrisonerControl")]
[ClassInterface(ClassInterfaceType.AutoDual)]
public class Class1
{
public Class1()
{
MessageBox.Show("FIRETRUCK!!!");
}
}
}
- 属性=>应用程序=>程序集信息=>请大会COM可见
- 构建=>注册为COM Interop True(选中)
- 做出assemply(签名)强名称
- 生成项目
regasm MYDLL.DLL/TLB /代码库
无法看到Prisoner.PrisonerControl在tstcon32 =(
需要帮助 谢谢
UPD:工作如VB脚本:
Dim objJava
Set objJava = WScript.CreateObject("Prisoner.PrisonerControl")
,但它不是在tstcon32,为什么...
UPD2可见:也许是因为tstcon32只为控制?
通灵调试:您位于x64系统上,tstcon32是32位进程,用于在注册表的WOW64部分中搜索activeX对象。 –
@VirtualBlackFox,谢谢,但是我的操作系统是WinXP x86 =( – VextoR
)打开注册表编辑器,在HKEY_CLASSES_ROOT下查找包含你的progid的文件夹“Prisoner.PrisonerControl”,如果有,那么抓住该键下面的CLSID值。现在,查看该CLSID的较早的HKEY_CLASSES_ROOT/CLSID。假设找到了,那么请在InprocServer32下查看,它应该有用于您的程序集的路径,版本,ID等。如果所有这些都看起来不错,那么该程序集已经成功注册为com对象。 – user957902