1

I have some .Net functionality I am trying to use in VB6. I have followed several tutorials. I wrote a test program with success using the formula here: http://www.codeproject.com/Articles/3511/Exposing-NET-Components-to-COM

However, when I try to do it with my actual project, my ProgId doesn't show in the registry like my test file. I made sure property 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();
    }
}
}

and my progid...

using System;

namespace Controls.Graph.Web
{
    /// <summary>
    /// ProgID Constant
    /// </summary>
    public static class ProgIds
    {
        public const string GraphScript = "GraphData";
    }
}

I'm not sure which piece of the puzzle I'm missing here

EDIT: actually the Guid shows up in the registry however the Progid still is not. Any ideas/suggestions?

also made sure to do this: registered for com interop

Ted
  • 487
  • 2
  • 12
  • 23
  • How are you registering your assembly? Are you registering it as 32-bit or 64-bit? If you are registering under 32-bit you need to look in the WOW64 registry keys. – vcsjones Aug 21 '13 at 14:24
  • I'm not sure. How would I find out/specify which one I want? – Ted Aug 21 '13 at 14:30
  • OK, it looks like you have `Register for COM interop` taking care of that for you. Do you have your assembly strong-named signed (under the Signing option)? IIRC that's also required for exposing to COM. – vcsjones Aug 21 '13 at 14:33
  • I'm not really sure what that means, but I created one. Now what do I do with it? – Ted Aug 21 '13 at 14:52
  • 1
    Using a protected constructor means "do not allow anybody but me to create an instance". So you have no use for a progid. And none will be written. – Hans Passant Aug 21 '13 at 18:53
  • 1
    @vcsjones: You only need strong name signing when you put your assembly into GAC, otherwise it is not necessary and it is completely unrelated to exposing the assembly to COM http://stackoverflow.com/q/4864892/57428 – sharptooth Aug 22 '13 at 06:54
  • @sharptooth fascinating! Today I learn! – vcsjones Aug 22 '13 at 12:54

1 Answers1

0

I have figured out what was wrong. I needed to change some access modifiers to PUBLIC -- including my GraphScript() constructor.

Ted
  • 487
  • 2
  • 12
  • 23