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 6057175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:27:33+00:00 2026-05-23T08:27:33+00:00

I have in existing COM-interface. I wan’t to create a .net assembly that exposes

  • 0

I have in existing COM-interface. I wan’t to create a .net assembly that exposes a new interface as COM (with a new GUID), but the structure of the interface needs to be the same.

How can i create a .net class (C#) that exposes this interface?

[
  odl,
  uuid(1ED4C594-DDD7-402F-90DE-7F85D65560C4),
  hidden,
  oleautomation
]
interface _IFlashPhase : IUnknown {

    [propget]
    HRESULT _stdcall ComponentName(
                    [in] short i, 
                    [out, retval] BSTR* pVal);
    [propput]
    HRESULT _stdcall ComponentName(
                    [in] short i, 
                    [in] BSTR pVal);
    [propget]
    HRESULT _stdcall ComponentMolePercent(
                    [in] short i, 
                    [out, retval] double* pVal);
    [propput]
    HRESULT _stdcall ComponentMolePercent(
                    [in] short i, 
                    [in] double pVal);
    [propget]
    HRESULT _stdcall ComponentFugacity(
                    [in] short i, 
                    [out, retval] double* pVal);
    [propput]
    HRESULT _stdcall ComponentFugacity(
                    [in] short i, 
                    [in] double pVal);

};
  • 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-23T08:27:34+00:00Added an answer on May 23, 2026 at 8:27 am

    Your IDL isn’t valid, an interface that is attributed with [oleautomation] should derive from IDispatch, not IUnknown. I’ll give the proper declarations and hint where you need to modify them to get yours.

    You cannot declare indexed properties in C#, the C# team refuses to implement them. Version 4 has support for indexed properties that are declared in a COM type library but still doesn’t allow declaring them yourself. The workaround is to use the VB.NET language, it has no qualms about it. Add a VB.NET class library project to your solution. Make it look similar to this:

    Imports System.Runtime.InteropServices
    
    Namespace Mumble
    
        <ComVisible(True)> _
        <Guid("2352FDD4-F7C9-443a-BC3F-3EE230EF6C1B")> _
        <InterfaceType(ComInterfaceType.InterfaceIsDual)> _
        Public Interface IExample
            <DispId(0)> _
            Property Indexer(ByVal index As Integer) As Integer
            <DispId(1)> _
            Property SomeProperty(ByVal index As Integer) As String
        End Interface
    
    End Namespace
    

    Note the use of <DispId>, dispid 0 is special, it is the default property of an interface. This corresponds to the indexer in the C# language.

    All you need VB.NET for is the declaration, you can still write the implementation of the interface in the C# language. Project + Add Reference, Projects tab and select the VB.NET project. Make it look similar to this:

    using System;
    using System.Runtime.InteropServices;
    
    namespace Mumble {
        [ComVisible(true)]
        [Guid("8B72CE6C-511F-456e-B71B-ED3B3A09A03C")]
        [ClassInterface(ClassInterfaceType.None)]
        public class Implementation : ClassLibrary2.Mumble.IExample {
            public int get_Indexer(int index) {
                return index;
            }
            public void set_Indexer(int index, int Value) {
            }
    
            public string get_SomeProperty(int index) {
                return index.ToString();
            }
    
            public void set_SomeProperty(int index, string Value) {
            }
        }
    }
    

    You need to run Tlbexp.exe on both the VB.NET and the C# assembly to generate the type libraries. The C# one with the implementation includes the VB.NET one.

    To get the interface to derive from IUnknown instead of IDispatch, edit the interface declaration. Remove the DispId attributes and use ComInterfaceType.InterfaceIsUnknown.

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

Sidebar

Related Questions

I have existing java code and need to create Design Document based on that.
We have an existing ServiceContract [ServiceContract(Namespace = http://somesite.com/ConversationService)] public interface IConversationService { [OperationContract(IsOneWay =
Say we have an existing process (or application) that calls a COM object from
I have a COM Interop DLL that I'm automatically generating from an existing COM
I have an existing regex: /^http:\/\/twitter\.com\/(\w+)\/status(es)*\/(\d+)$/ that I use for determining if a URL
I have an existing asp.net web app that uses facebook to authenticate users. I
I have existing code that uses CMNewProfileSearch to find then iterate over the color
For whatever reason, I have a lot of clients that have existing data that's
We have an existing WCF service that makes use of wsDualHttpBinding to enable callbacks
For historical reasons, we need to expose string constants in .NET through COM interface.

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.