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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T16:20:26+00:00 2026-05-19T16:20:26+00:00

I am writing an app in C#, that connects to an old-skool COM object

  • 0

I am writing an app in C#, that connects to an old-skool COM object via IDispatch. I do this with this sort of code:

public sealed class Attachments
{
    Object comObject;
    Type type;

    private readonly static Attachments _instance = new Attachments();
    public static Attachments Instance  { get { return _instance; } }

    private Attachments()
    {
        type = Type.GetTypeFromProgID("WinFax.Attachments");
        if (type == null)
            throw new ArgumentException("WinFax Pro is not installed.");
        comObject = Activator.CreateInstance(type);
    }

    public Int16 Count()
    {
        Int16 x = (Int16) type.InvokeMember("Count",
                                            BindingFlags.InvokeMethod,
                                            null,
                                            comObject,
                                            null);
        return x;
    }
    ....

One of the methods on this IDispatch interface returns an LPDISPATCH, which I take it is a Long Pointer to IDispatch. It is another COM object, ProgId WinFax.Attachment. (WinFax.Attachments manages a collection of WinFax.Attachment objects.)

In C#, How do I call methods on the COM object corresponding to that LPDISPATCH? Can I just do something like this:

    Object o = type.InvokeMember("MethodReturnsLpdispatch",
                                     BindingFlags.InvokeMethod,
                                     null,
                                     comObject,
                                     null);
    Type t2 = Type.GetTypeFromProgID("WinFax.Attachment"); // different ProgId !!
    Object x = t2.InvokeMember("MethodOnSecondComObject",  
                                     BindingFlags.InvokeMethod,
                                     null,
                                     o,
                                     null);
  • 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-19T16:20:27+00:00Added an answer on May 19, 2026 at 4:20 pm

    yes, this works:

        Type type = Type.GetTypeFromProgID("WinFax.Attachments");
        if (type == null)
              throw new ArgumentException("WinFax Pro is not installed.");
        Object comObject = Activator.CreateInstance(type);  
        Object o2 = type.InvokeMember("MethodReturnsLpdispatch",
                                         BindingFlags.InvokeMethod,
                                         null,
                                         comObject,
                                         null);
        Type t2 = Type.GetTypeFromProgID("WinFax.Attachment"); // different ProgId !!
        Object x = t2.InvokeMember("MethodOnSecondComObject",  
                                         BindingFlags.InvokeMethod,
                                         null,
                                         o2,
                                         null);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing front end app that connects to a DB and downloads any
I am writing a VB.NET app that connects to a legacy application using TCP.
I'm writing an iPhone app that can be started via a custom URL. So,
I'm writing a .NET app that connects to a remote hosted SQL Server. Researching
I'm writing an app that connects to network resources. When the app is connecting,
I am writing an app that in some situations warns user with an alarm
I'm writing an app that will need to make use of Timer s, but
I'm writing an app that contains the following tables: (1) employee_type, (2) employee and
I'm writing an app that lets a diabetic user enter his/her blood glucose readings,
I'm writing an app that supposed to copy a bunch of files from one

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.