SEHException

Introduction

We've recently received reports from clients who experience intermittent crashes of .NET applications, when running from a network location or a mapped drive, possibly under Remote Desktop session.

Symptoms

When running the application from a mapped drive or a network location, the application crashes during execution. The .NET error details, which can also be found the in Windows Event Viewer, are similar to the following:

Exception Info: System.Runtime.InteropServices.SEHException

or 

System.TypeLoadException - Abstract factory failed to load class 'xxxxxxxx' in assembly 'xxxxxxx' 

The Cause

This is a known Microsoft issue in Windows Server 2008 and Windows Server 2012, as described in this article

Our Solutions

  1. Run the application locally from the user's machine instead from the server.

  2. Use mklink to create a symbolic link.

    Symbolic link are used to create a local folder that points to a remote server folder. The folder created by the Symbolic links are transparent to users. and appear as normal local folder. Using the mklink command allow you to point your user to the exe file on its local Hard drive.

    This method allow you to enjoy the two worlds :

    1. The application will be running form the local HD - this will solve the problem.
    2. You do not need to copy the application to your user's local drive, every time you have a new version.

To implement this please open command line window, and run this command :

mklink /D c:\northwind-linked \\trainingpc\c\Northwind\Dotnet" 

/D = Switch creates a directory symbolic link.

c:\northwind-linked = the name of the new folder that will be created for you on your hard drive.

\\trainingpc\c\Northwind\Dotnet = remote folder that have the application files.

Now you can see on your local hard drive a new folder named northwind-linked, and you can run the application from there.

2018 12 04 14h16 10

If needed, you can create a northwind.Bat file that will do that for the end user:

If not exist c:\northwind-linked mklink /D C:\northwind-linked \\trainingpc\c\Northwind\Dotnet

c:
cd c:\northwind-linked
start northwind.exe /ini=northwind.ini 

  1. We've developed a small utility called AppRunner, which allows you to run the application from a network location, without having this issue. You can download AppRunner from this link

For details about how to use it please refer to the ReadMe page


Help us improve, Edit this page on GitHub
or email us at info@fireflymigration.com