473,396 Members | 1,840 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Make Single Instance Application VS 2005

Hi

I have search for the above said issue and it gives me the same solution that it has option in application properties application tab. But Somehow I am not able to see the same can any one help me please

Find attached image

Oct 3 '08 #1
3 1510
joedeene
583 512MB
try the settings tab under property?

joedeene
Oct 3 '08 #2
Curtis Rutland
3,256 Expert 2GB
try this link out. Not the method you are looking for, but a different means to the same end.
Oct 3 '08 #3
tlhintoq
3,525 Expert 2GB
Plan B: Use a little code from VB.
Be sure to add a reference to Microsoft Visual Basic then add this code to your Program.CS file

Expand|Select|Wrap|Line Numbers
  1.         /// <summary>
  2.         /// The main entry point for the application.
  3.         /// </summary>
  4.         [STAThread]
  5.         static void Main(string[] commandLine)
  6.         {
  7.             Control.CheckForIllegalCrossThreadCalls = false;
  8.             if (bSplash) SplashScreen.ShowSplashScreen();
  9.             if (bSplash) SplashScreen.SetStatus("Getting Environmental information");
  10.  
  11.             Application.EnableVisualStyles();
  12.             App myApp = new App();
  13.             myApp.Run(commandLine);
  14.         }
  15.     }
  16.  
  17.  
  18.  
  19.     /// <summary>
  20.     ///  We inherit from WindowsFormApplicationBase which contains the logic for the application model, including
  21.     ///  the single-instance functionality.
  22.     /// </summary>
  23.     class App : Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase
  24.     {
  25.         public App()
  26.         {
  27.             this.IsSingleInstance = true; // makes this a single-instance app
  28.             this.EnableVisualStyles = true; // C# windowsForms apps typically turn this on.  We'll do the same thing here.
  29.             this.ShutdownStyle = Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses; // the vb app model supports two different shutdown styles.  We'll use this one for the sample.
  30.         }
  31.  
  32.         /// <summary>
  33.         /// This is how the application model learns what the main form is
  34.         /// </summary>
  35.         protected override void OnCreateMainForm()
  36.         {
  37.             this.MainForm = new Form1();
  38.         }
  39.  
  40.  
  41.         /// <summary>
  42.         /// Gets called when subsequent application launches occur.  The subsequent app launch will result in this function getting called
  43.         /// and then the subsequent instances will just exit.  You might use this method to open the requested doc, or whatever 
  44.         /// </summary>
  45.         /// <param name="eventArgs"></param>
  46.         protected override void OnStartupNextInstance(Microsoft.VisualBasic.ApplicationServices.StartupNextInstanceEventArgs eventArgs)
  47.         {
  48.             base.OnStartupNextInstance(eventArgs);
  49.             //System.Windows.Forms.MessageBox.Show("An attempt to launch another instance of this app was made");
  50.         }
  51.  
  52.     }
  53.  
You probably want to delete or comment out lines 8 and 9 since they are for a splash screen that won't exist in your project.
Oct 4 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Trung | last post by:
Hi everybody I write a class named SharedClass that holds catched data that would be available for all clients by using static method/member. This class is registered in the assembly folder....
16
by: Elad | last post by:
Hi, I have an application that is made up of several executables. I need all these executables to use the same instance of an object. What is the best, most efficient way to approach this? ...
18
by: Steve Barnett | last post by:
I want to ensure that there is only ever one instance of my app running on a single PC at any time. I understand that I can achieve this by using a mutex and, if I can't take ownership of the...
1
by: smith | last post by:
I was recently set to release an app that used very common single instance code and hit the oddest issue. After many hours of full build tests I believe that it is duplicatable. Environment: ...
9
by: MrSpock | last post by:
1. Create a new Windows Application project. 2. Open the project properties and check "Make single instance application". 3. Build. 4. Go to the release folder and run the application. 5. Try to...
7
by: Jeffery Tyree | last post by:
I am writing an application in C#.NET that is "AlwaysOnTop" and there should only be one instance of this program running at any given time. The "AlwaysOnTop" piece is working just fine but I...
5
by: natzol | last post by:
Is there a way to run query, make file out of query (txt,csv or xls - for example) and save it as a blob into the table column type Image/Text? Any thoughts would be greatly appreciated. ...
3
by: bloreboy | last post by:
Hi, In .Net 2005 Win forms, My application will generate a file with the extention of .rrt. When ever i m opening this file from any location it has to associate with my applicaiton and open in...
1
by: Manish | last post by:
Hi i have a problem where as i want to use two different C# net program in a single system where i have used 2 different sql server name. when i execute those program each time iam renaming the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.