Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Articles
Search: 

Bonnie Berent's Tips
Bonnie DeWitt, February 1, 2006
Great tips for .NET developers
Summary
Great tips for .NET developers
Description

Run EXE From a Network Drive
How do you set a shortcut on a workstation to run an EXE on a network drive? You need to change your security settings to allow Full Trust on the intranet.
Open the Control Panel
Open Administrative tools
Open Microsoft .Net Framework 1.1 Wizards
Click Adjust .Net Security
Click Next
Select Local Intranet
Change the level of trust to Full
Click Next
Click Finish

from a solution provided by Eric Moreau in Message #1039491

SELECT COUNT(*)
Consider the following SQL statement:
string MySQLString = @"Select count(*) from customer
                       where city = 'Walla Walla'";

Your first reaction might be to use this statement to fill a DataSet with a one row, one column Table in order to get the count. This would work, but why have all the overhead of a DataSet? A better approach is to use the ExecuteScalar() method instead:

OleDbConnection loConnection = new OleDbConnection(MyConnectString);
loConnection.Open();
OleDbCommand cmd = new OleDbCommand(MySQLString, loConnection);
int iCount = Convert.ToInt32(cmd.ExecuteScalar());

Note the use of Convert.ToInt32 ... this is to keep your code back-end independent, as some databases may return a count other than an integer.

from a solution provided by Çetin Basöz in Message #1005874 and Message #1006094

Run ASP.NET 1.1 and 2.0 On Same Server
You can't run the two versions of .NET in the same process, however, you can easily configure your Web Server so that each application uses it's own process or a shared process for all .NET 1.1 or 2.0 applications.

In IIS 6 you can set up an Application Pool and assign your application to that Application Pool. A Pool is an individual process so you'd create one Pool for all 1.1 apps and one Pool for all 2.x apps, and then assign each virtual or site to the appropriate pool.

In IIS 5 you have to use High Isolation Mode to accomplish the same thing.

from a solution provided by Rick Strahl in Message #1082200

Forms Handler
Using a FormsHandler in your applications is a good idea, because it allows you to easily close all Forms that remain open when the entire application closes.

First the FormsHandler class. Notice the static methods.
using System;
using System.Collections;
using System.Windows.Forms;

namespace MyNameSpace.MyClasses
{
   public class FormsHandler
   {
      #region Declarations
      private static ArrayList list = new ArrayList();
      #endregion

      #region Methods
      public static int Add(object o)
      {
         return list.Add(o);
      }
      public static void Remove(object o)
      {
         list.Remove(o);
      }
      public static bool Close()
      {
         int nCount = list.Count;
         while (list.Count > 0)
         {
            ((Form)list[0]).Close();
            if (list.Count == nCount)
               return false;
            else
               nCount = list.Count;
         }

         return true;
      }
      #endregion

      #region Properties
      public static ArrayList List
      {
         get {return list;}
      }
      #endregion
   }
}
Whenever you open a form, no matter where you open it from, all you do is add it to the ArrayList, like this:
Form oForm = new MyForm();
FormsHandler.Add(oForm);
oForm.Show();

When you close your Main Form, you want all other's to Close (but to execute their own Closing methods) ... do it like this:
// This is a menu item that exits the application

private void menuItem4_Click(object sender, System.EventArgs e)
{
   System.ComponentModel.CancelEventArgs ee = new CancelEventArgs();
   this.ClosingHandler(sender, ee);
}

// This is the ClosingHandler that will execute normally if you close the app
// by clicking on the "X"

private void ClosingHandler(object sender, System.ComponentModel.CancelEventArgs e)
{
   if (!FormsHandler.Close())
      e.Cancel = true;
   else
      Application.Exit();
}

from a solution provided by Bonnie Berent in Message #1056744

Bonnie DeWitt, Geneva Systems Group
Bonnie is currently one of the principals of Geneva Systems Group. Call her the Senior Software Engineer, or even call her the VP of Engineering. She has no official title at the moment. Bonnie has been writing software in various languages for about 30 years. Bonnie's current focus on C# .NET applications began in early 2002. She has been a Microsoft C# MVP since Oct 2003 and an active member of the .NET online community.
More articles from this author
Bonnie DeWitt, September 1, 2005
Great tips for .NET developers
Bonnie DeWitt, October 1, 2005
Great tips for .NET developers
Bonnie DeWitt, November 1, 2005
Great tips for .NET developers
Bonnie DeWitt, December 1, 2005
Great tips for .NET developers
Bonnie DeWitt, April 1, 2009
Great tips from the .NET developer community compiled by Bonnie Berent.
Bonnie DeWitt, March 1, 2006
Great tips for .NET developers
Bonnie DeWitt, April 1, 2006
Great tips for .NET developers
Bonnie DeWitt, May 1, 2006
Great tips for .NET developers
Bonnie DeWitt, June 1, 2006
Great tips for .NET developers
Bonnie DeWitt, July 1, 2006
Great tips for .NET developers
Bonnie DeWitt, August 1, 2006
Great tips for .NET developers
Bonnie DeWitt, September 1, 2006
Great tips for .NET developers
Bonnie DeWitt, October 1, 2006
Great tips for .NET developers
Bonnie DeWitt, November 1, 2006
Great tips for .NET developers
Bonnie DeWitt, December 1, 2006
Great tips for .NET developers
Bonnie DeWitt, January 1, 2007
Great tips for .NET developers
Bonnie DeWitt, February 1, 2007
Great tips for .NET developers.
Bonnie DeWitt, March 1, 2006
Great tips for .NET developers.
Bonnie DeWitt, April 1, 2007
Great tips for .NET developers.
Bonnie DeWitt, March 1, 2007
Good tips for .NET developers.
Bonnie DeWitt, May 1, 2007
Great tips for .NET developers.
Bonnie DeWitt, June 1, 2007
Great tips and tricks for .NET developers.
Bonnie DeWitt, July 1, 2007
Great tips for .NET developers.
Bonnie DeWitt, August 1, 2007
Great tips for .NET developers
Bonnie DeWitt, September 1, 2007
Great tips for .NET developers.
Bonnie DeWitt, February 1, 2008
Great tips from the Universal Thread .NET community.
Bonnie DeWitt, March 1, 2008
Great tips for .NET developers selected from the community by Bonnie Berent.
Bonnie DeWitt, April 1, 2008
Great tips from the .NET developer community compiled by Bonnie Berent.
Bonnie DeWitt, January 1, 2006
Great tips for .NET developers