2013-08-21 49 views
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仍然不是。任何想法/建议?

还确保做到这一点: registered for com interop

+0

你如何注册你的程序集?你注册为32位还是64位?如果您在32位以下注册,则需要查看WOW64注册表项。 – vcsjones

+0

我不确定。我如何找出/指定我想要哪一个? – Ted

+0

好吧,它看起来像你有'注册COM互操作'为你照顾。你有你的程序集强命名签名(签名选项下)? IIRC也是暴露给COM的必要条件。 – vcsjones

回答

0

我已经想通了,什么是错的。我需要将一些访问修饰符更改为PUBLIC - 包括我的GraphScript()构造函数。