Table of Contents

C# (c sharp)

C# is the programming language of choice for developing .Net applications on Windows.

Visual Studio Express

Errors when running an executable from a network location

.Net is by default configured with CAS (code access security). This causes the executable to throw an exception if security permissions are not configured properly. If the application does not handle this exception, then the user will see an error that lacks information, and gives the appearance that your application is broken (your fault).

To remedy the situation, you need to do something about CAS. The recommended solution is to handle the error.

edit program.cs...

// standard namespaces (for this app)
using System;
using System.Collections.Generic;
using System.Windows.Forms;

// add the following namespaces
using System.Security;
using System.Security.Permissions;

// modify the class to handle the error, similar to the following:
namespace ChecksumUtility
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {

            try
            {
                // Demand full trust permissions
                PermissionSet fullTrust = new
                                PermissionSet(PermissionState.Unrestricted);
                fullTrust.Demand();

                // Perform normal application logic
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new Form1());

                // Report that permissions were not full trust
            }
            catch (SecurityException)
            {
                MessageBox.Show("This application requires full-trust " +
                    "security permissions to execute." +
                    "(maybe you are trying to run this from a network?)");
            } 




        }
    }
}

Encryption