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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:42:51+00:00 2026-06-08T08:42:51+00:00

I have a simple C# library that I have registered for COM interop. I

  • 0

I have a simple C# library that I have registered for COM interop. I have added a reference for this to my vb6 app. I ran my vb application and everything works fine. What I would like to know is how does this work. I checked the task mamager and I see VB6.exe in the processes but I cannot see anything relating to .net.

code: vb6

Dim a As CsharpdllForVBHack.ComAdder
Private Sub Command1_Click()
    Set a = New CsharpdllForVBHack.ComAdder
    a.Add 1, 4
End Sub

code: C#.net

 [ComVisible(true)]
 public class ComAdder
 {
    [ComVisible(true)]
    public void add (int a,int b)
    {
        TestForm testForm = new TestForm(a+b);
        testForm.ShowDialog();
    }
 }

I would also like to know how would I handle disposing of this com object once I am done

We noticed that each time we click on the button and close the form the memory used goes up by a few 100 kb even adding set a= Nothing

  • 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-06-08T08:42:53+00:00Added an answer on June 8, 2026 at 8:42 am

    In your case, VB instantiates a COM Callable wrapper class (CCW) which lives inside the .NET assembly. The usual COM-type things happen here. First of all, COM looks up the GUID for the class in the registry, and finds the assembly DLL, which it loads into the process of the VB component. COM tries to find a function which retrieves a pointer to a standard COM interface, which you use to instantiate the COM class. You now have a COM object.

    But that is not the whole story. When you instantiate the CCW, it also ensures that the .NET runtime is loaded, and then creates an instance of the .NET class. Your COM object has an interface which is based on the .NET interface. The CCW essentially forwards all calls from the COM interface to the .NET interface, converting the COM data types to .NET data types, and back again if you have return values and out parameters.

    As for your second point – in this particular case, don’t bother. When VB gets to the end of the procedure (or Exit Sub, or raises an error), it jumps to a subroutine which clears down all procedure level variables. If object variables are cleared, the reference count to the COM object is decremented. If the reference count is zero, the COM instance kills itself.

    In your case, when the COM class kills itself, it takes extreme measures to ensure that the .NET object is destroyed, but you cannot rely on this behaviour, as with all .NET objects.

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

Sidebar

Related Questions

I have a simple JSF line chart that uses PrimeFaces (via jqPlot) library: <p:lineChart
I have developed a simple library in Ruby and need to use this in
I have a simple class library (COM+ service) written in C# to consume 5
I have gdata library install on my ArchLinux, and a simple application which imports
I have a simple class library that I use in Excel. Here is a
I have already added delay loading to my project, using the instructions in http://msdn.microsoft.com/en-us/library/151kt790.aspx
I have an monotouch application that includes an objective-c static library. The application runs
I have a simple tank wars style game using the allegro open source library.
When I'm testing my simple geometric library, I usually have one or two methods
Below, I have a simple program which uses the CImg library (http://cimg.sourceforge.net/) which iterates

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.