1
我有一些.Net功能,我嘗試在VB6中使用。我遵循了幾個教程。我寫了一個成功的測試程序,使用這裏的公式:http://www.codeproject.com/Articles/3511/Exposing-NET-Components-to-COM將.NET暴露給COM
然而,當我嘗試用我的實際項目做到這一點時,我的ProgId並沒有像我的測試文件那樣顯示在註冊表中。我確信屬性標記有ComVisible特性==真
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();
}
}
}
和我的progid ...
using System;
namespace Controls.Graph.Web
{
/// <summary>
/// ProgID Constant
/// </summary>
public static class ProgIds
{
public const string GraphScript = "GraphData";
}
}
我不知道我錯過這一塊拼圖這裏
編輯:實際上Guid出現在註冊表中但是Progid仍然不是。任何想法/建議?
還確保做到這一點:
你如何註冊你的程序集?你註冊爲32位還是64位?如果您在32位以下注冊,則需要查看WOW64註冊表項。 – vcsjones
我不確定。我如何找出/指定我想要哪一個? – Ted
好吧,它看起來像你有'註冊COM互操作'爲你照顧。你有你的程序集強命名簽名(簽名選項下)? IIRC也是暴露給COM的必要條件。 – vcsjones