Results 1 to 3 of 3

Thread: [2.0] Interacting with my app, other instance

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2003
    Posts
    89

    Resolved [2.0] Interacting with my app, other instance

    Hello,
    I restricted my application to only one instance. When the app is running and the user tries to launch it again, the new instance is not created and Application.Exit() is invoked instead.

    Now, here's the problem: just before invoking Application.Exit(), I want to send a string message to the main, running instance. How can I do this with some Win32 API or other managed -more elegant- way? I'd like to avoid .NET Remoting.

    Thanks for helping.
    Last edited by BrightSoul; Jan 2nd, 2007 at 09:03 AM.
    - mo! I said MOOOOOOO!!
    - ...yep, that's a cow, alright.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2.0] Interacting with my app, other instance

    VB 2005 has an inbuilt way to do this. You might like to investigate how that's done by opening the Framework assemblies involved using .NET Reflector. I have also seen numerous articles about incorporating the VB My namespace into C# applications. I'm not sure if that would completely or partly enable your using application events for this as is done in VB or not, but it's worth checking out. Failing that, this article has been around for some time and should help, if not completely solve, your problem. The code is VB but the principle is directly applicable to C#.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jun 2003
    Posts
    89

    Re: [2.0] Interacting with my app, other instance

    Yay! It works!
    It took me a while to figure out how to put it all together though.

    Failing that, this article has been around for some time and should help, if not completely solve, your problem
    Yes, it solved my problem completely. I tried to convert that code to C# at first, but I was unsuccesful because of some compile errors I didn't know how to get around. I then compiled both the main VB.NET code and the test form into an assembly and referenced it from my application. Finally, I inherited from the test form and wrote a little extra C# code.

    VB 2005 has an inbuilt way to do this. You might like to investigate how that's done by opening the Framework assemblies involved using .NET Reflector.
    I'd love to, but I don't really know what classes I should start inspecting first

    Thanks for helping
    - mo! I said MOOOOOOO!!
    - ...yep, that's a cow, alright.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width