目前,我正在遵循这一程序:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace TestAgain
{
public class Test
{
void testIt() {
MessageBox.Show("Yellow world");
}
}
}[assembly: ComVisible(false)]设置为[assembly: ComVisible(true)]。"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\RegAsm.exe" -tlb -codebase "C:\Users\sancarn\Desktop\tbd\TestAgain\TestAgain\bin\Debug\TestAgain.dll" -verboseregasm的产出如下:
Microsoft .NET Framework Assembly Registration Utility version 4.7.3056.0
for Microsoft .NET Framework version 4.7.3056.0
Copyright (C) Microsoft Corporation. All rights reserved.
Types registered successfully
Type 'TestAgain.Test' exported.
Assembly exported to 'C:\Users\sancarn\Desktop\tbd\TestAgain\TestAgain\bin\Debug\TestAgain.tlb', and the type library was registered successfully因此,类型TestAgain.Test被导出,类型库已经注册。太棒了!
所以我使用Excel测试它:
Sub testIt()
Dim o As Object
Set o = CreateObject("TestAgain.Test")
Call o.testIt
End Sub并得到错误Error 429: ActiveX component can't create object。它没有注册吗?
有人知道为什么这不管用吗?
注意:我已经成功地获得了一个Com可见的应用程序与接口but I've been looking for a cleaner method和一个用户告诉我,雷杰姆可以完成这项工作。
发布于 2018-08-07 12:20:29
我已经知道了,但我忘了这件事:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace TestAgain
{
public class Test
{
public void testIt() {
MessageBox.Show("Yellow world");
}
}
}这就像一种魅力。
https://stackoverflow.com/questions/51723792
复制相似问题