Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6804679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:29:45+00:00 2026-05-26T19:29:45+00:00

I’m sure the answer to my issue is a combination of many threads already

  • 0

I’m sure the answer to my issue is a combination of many threads already present on this forum. Maybe you can help me put the pieces together.

So my challenge is, I have some C++ code that implements an interface that looks like this:

interface ItsSupplier : IDispatch {
    [propget, id(1), helpstring("property name") HRESULT Name([out, retval] BSTR* pVal);
}

The DLL which implements this interface, is a usable plugin in a third party software.
I want to make a plugin written in .NET.
Since the software using the plugins is not .NET, I asume that the DLL have to be a COM object.

Here is how I go about it in .NET.

[Guid("xxxx")]
public interface ItsSupplier {
    [DispId(1)]
    [return: MarshalAs(UnmanagedType.Bstr)]
    string Name { get; }
}

[Guid("xxxx"),
ClassInterface(ClassInterfaceType.AutoDispatch),
ComSourceInterfaces(typeof(ItsSupplier))]
    public class SupplierClass : ItsSupplier
    {
        public string { get { return "someName"; } }
    }
}

Under project settings, I have checked “Register for COM interorp”.

After build I run “regasm testDll.dll”

My questions are …

Is it the right way to define the ItsSupplier interface myself? I mean, this is a interface which the third party software expects, so will it have to be referenced somwhere else?

Am I doing it right, when it comes to the COM interop part?

I hope I’m explaining this right 🙂

Cheers
/Thomas

—————- EDIT AFTER RESPONSE FROM HANS ————————

When i build the tlb file and view the original and my version in Oleview, this is what I get.

Here is what the original interface plugin looks like in Oleview:

[
  odl,
  uuid(370B4079-40BB-47C9-B797-33B3B5422685),
  helpstring("ItsSupplier Interface"),
  dual,
  oleautomation
]
interface ItsSupplier : IDispatch {

Here is what mine looks like:

[
  odl,
  uuid(370B4079-40BB-47C9-B797-33B3B5422685),
  version(1.0),
  dual,
  oleautomation,
  custom(0F21F359-AB84-41E8-9A78-36D110E6D2F9, "COMDLL.ItsSupplier")    

]
interface COMDLL_ItsSupplier : IDispatch {

The “COMDLL” Is the name of my visual studio project. Do you think that matters?

/Thomas

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T19:29:46+00:00Added an answer on May 26, 2026 at 7:29 pm

    No, lots of subtle mistakes that will get you into trouble. First off, the c++ interface declares a dual interface, supporting both early binding and late binding through IDispatch. You have to use the [InterfaceType] attribute in .NET to get the same:

    [ComVisible(true)]
    [Guid("xxxx")]
    [InterfaceType(ComInterfaceType.InterfaceIsDual)]
    public interface ItsSupplier {
        [DispId(1)]
        string Name { get; }
    }
    

    Be sure to use the exact same guid, it wasn’t visible in your snippet. The [MarshalAs] attribute is unnecessary, the string already marshals as a BSTR.

    Next is the class. You do not want to expose the class implementation. That forces the client code to also beware of System.Object, the base class of all .NET classes. It will appear in the type library. Using [ComSourceInterfaces] is incorrect, that should only be applied to dispinterfaces for events.

    [ComVisible(true)]
    [Guid("xxxx")]
    [ClassInterface(ClassInterfaceType.None)]
    public class SupplierClass : ItsSupplier
    {
        public string Name {
            get { return "someName"; }
        }
    }
    

    Again use the exact same guid as used in the IDL file. Next is registration. Using the “Register for COM interop” option is fine but then do not run Regasm.exe again. You’ll mess up the registration with that. If you do prefer to register by hand then always use the /codebase option so the assembly doesn’t have to be installed in the GAC.

    The ultimate check that you got everything right is to create the type library with Tlbexp.exe and view it with Oleview.exe, File + View Typelib. It should be an exact match with your IDL.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm not entirely sure how I managed to jack this up. http://pretty-senshi.com If you
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Does anyone know how can I replace this 2 symbol below from the string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.