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

  • Home
  • SEARCH
  • 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 4004580
In Process

The Archive Base Latest Questions

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

I am currently working with COM objects in managed code and am using the

  • 0

I am currently working with COM objects in managed code and am using the new dynamic type for this. This works well in some areas but can be an issue in others.

I was think about how I could get the best of both worlds, the flexibility of the dynamic type (late bound) with the support for say, an RCW (early bound)

Somehow wrapping the dynamic type in a more manageable stucture. I was wondering if there was a preferred method for this (if it is even a good idea) or what things I should consider.

The two basic ideas I came up with so far as follows:

Firstly, creating a static class that allows me to call the methods of the dynamic type in a managed way.

public static class ComObjectWrapper
{
   public static void SomeMethod(dynamic comObject, int x)
   {
      comObject.someMethod(x);
   }

   public static bool GetSomeProp(dynamic comObject)
   {
      comObject.getSomeProp();
   }

   public static void SetSomeProp(dynamic comObject, bool foo)
   {
      comObject.setSomeProp(foo);
   }
}

Secondly, creating a class that is constructed using the com object, then mapping all its members to managed properties, methods, etc.

public class ComObjectWrapper
{
   private dynamic comObject = null;

   public ComObjectWrapper(dynamic comObject)
   {
     this.comObject = comObject;
   }

   public void SomeMethod(int x)
   {
      comObject.someMethod(x);
   }

   public bool SomeProp
   {
      get
      {
         return comObject.getSomeProp();
      }
      set
      {
         comObject.setSomeProp(value);
      }
   }
}

Are there other ways to approach this? Am I missing something stupid!?

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

    The opensource framework Impromptu-Interface will wrap a dynamic object with a static interface such that all the statically defined members from the interface use the dlr to forward to the dynamic object.

    Create Your interface

    IComObjectWrapper
    {
       void SomeMethod(int x);
       bool SomeProp;
    }
    

    Then where you need to wrap your com object include ImpromptuInterface

      using ImpromptuInterface;
    

    And finally to wrap it:

    var tStaticTyped = Impromptu.ActLike<IComObjectWrapper>(comObject);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The system I am currently working on requires some role-based security, which is well
I am currently doing IE-hacks on a website I'm working on: http://www.timkjaerlange.com/wip/co2penhagen/ I got
I'm currently working on creating a new C# project that needs to interact with
The company I'm currently working for is using Selenium for Uniting-Testing our User Interface.
I am pretty new to iPhone development and currently working on an application which
I currently working on an issue tracker for my company to help them keep
I am currently working on a project and my goal is to locate text
I am currently working on a project with specific requirements. A brief overview of
I'm currently working at a small web development company, we mostly do campaign sites
We are currently working in a private beta and so are still in the

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.