我尝试在 VB6 中使用一些 .Net 功能。我遵循了几个教程。我在这里使用公式成功编写了一个测试程序:http: //www.codeproject.com/Articles/3511/Exposing-NET-Components-to-COM
但是,当我尝试对我的实际项目执行此操作时,我的 ProgId 不会像我的测试文件一样显示在注册表中。我确保属性 ComVisible == true
using System.Runtime.InteropServices;
namespace Controls.Graph.Web
{
[Guid("5F9F6C6F-016A-4CFF-BD7A-3463761807E1")]
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface _GraphScript
{
[DispId(1)]
string getGraphXml();
}
[Guid("35901BC6-EFF1-490C-84FA-786E8462C553")]
[ClassInterface(ClassInterfaceType.None)]
[ProgId(ProgIds.GraphScript)]
public class GraphScript : _GraphScript
{
protected GraphScript()
{
}
/// <summary>
///
/// </summary>
/// <returns>The graphs xml and javascript</returns>
public string getGraphXml()
{
DisplayDefaults tempDefaults;
tempDefaults = new DisplayDefaults();
GraphConstructor graph = new GraphConstructor();
graph.constructGraph();
GraphModel completedGraph = graph.Graph;
return GraphControl.RenderGraph(completedGraph, tempDefaults, 1) + GraphControl.RenderGraphScript();
}
}
}
和我的天才...
using System;
namespace Controls.Graph.Web
{
/// <summary>
/// ProgID Constant
/// </summary>
public static class ProgIds
{
public const string GraphScript = "GraphData";
}
}
我不确定我在这里缺少哪一块拼图
编辑:实际上 Guid 显示在注册表中,但 Progid 仍然没有。有什么想法/建议吗?
还确保这样做: