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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:48:50+00:00 2026-06-08T09:48:50+00:00

I created a COM Visible DLL in C# that should show a Form after

  • 0

I created a COM Visible DLL in C# that should show a Form after some inputs from the User in the host application (unmanaged). It works fine with ShowDialog(), but ideally the Form should keep running even after the DLL finishes. Because the Form need some Data a separated Project with Main(string[] args) is not an option.

How can I accomplish this? I tried something like that but it didn’t worked.

public class FormManager : ApplicationContext
{
    FormMain frmMain;


    public FormManager()
        :base(new FormMain())
    {
        frmMain = (FormMain)this.MainForm;
        frmMain.Closed += new EventHandler(OnFormClosed);
    }

    public void SetData(object o1, object o2)
    {
        if (frmMain != null)
        {
            frmMain.SetData(o1, o2);
            frmMain.Show();
        }
    }

    private void OnFormClosed(object sender, EventArgs e)
    {
            ExitThread();
    }
}

I have no idea where Application.Run should be inserted.

  • 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-08T09:48:52+00:00Added an answer on June 8, 2026 at 9:48 am

    I, too, am a little unclear as to what exactly you are trying to do here… but normally, if you are placing the Application.Run somewhere in that code, it would be in place of this line:

    frmMain.Show();
    

    Of course, by using Application.Run you will be freezing this code (the thread that calls Application.Run) until the form in question closes… So maybe that doesn’t really accomplish what you want (it is, indeed, unclear).


    Edit After Clarification of Question


    Here’s the thing about COM in .NET that was not true about previous iterations of Microsoft languages. When you call an assembly in .NET via COM (OLE) the calling assembly subsumes the COM exposed code into its runtime. In other words, when you look in the Task Manager, you won’t see both of your assemblies running! You’ll only see the one that did the calling. Thus, when you close the main assembly, you close any running code attached to it, including your COM code.

    There is one way around this, but it’s not simple. In short, you would need to:

    1. Launch your second process (you could, for instance, use a Process.Start())
    2. Use the first process to look inside the ROT (Running Objects Table) and locate the second assembly
    3. Communicate freely via COM (OLE) and pass your data

    At this point, the two assemblies are running in separate runtimes, which will allow you to produce forms in the second assembly that will not close when the first assembly closes. That, as I understand it, is what you’re looking for.

    If you want to try this route, do a little Googling for the ROT and try some sample code. If you have questions about that let me know!

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

Sidebar

Related Questions

I have created a .NET DLL which makes some methods COM visible. One method
The Situation: I created a DLL in C# that uses COM to run Process.Start
I have a COM visible .NET DLL file that is being used as an
I need to develop some classes that should be callable from VB6 with Managed
I have created a COM enabled .NET User Control and am wondering what is
I created an applet using RXTXComm.jar to read values from a COM port. When
I created a WCF service that uses TagLib# ( http://developer.novell.com/wiki/index.php/TagLib_Sharp ) which relies on
I've created a facebook fbml/api page that returns some content and it works. I
I am building an application that has the functionality like 3 tabs created using
Hello I created COM visible class MyClass on C# registered by regasm command -

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.