当前,我正在执行以下步骤:
.
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" -verbose
因此,类型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
已导出,并且类型库已注册。太好了!
所以我转到Excel-VBA并使用以下工具进行测试:
TestAgain.Test
并得到错误Sub testIt()
Dim o As Object
Set o = CreateObject("TestAgain.Test")
Call o.testIt
End Sub
。即它没有注册?
有没有人知道为什么它不起作用?
注意:在使用界面but I've been looking for a cleaner method之前,我已经设法获得了Com-Visible应用程序,并且用户告诉我再加气可以完成这项工作。
答案 0 :(得分:0)
我已经知道这一点,但是却让我忘了:
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");
}
}
}
这就像一种魅力。