Arris Ray

Arris Ray

  • NA
  • 1
  • 0

FileLoadException when running a C# Windows Forms application on removable media

Jun 24 2008 11:35 AM
Disclaimer: This problem doesnt' regard a VS.NET Setup & Deployment project but does pertain to deployment of a C# winforms application onto other systems/devices. If this community feels that this topic would be more appropriate on another forum, please let me know.

Environment: Visual Studio 2008, C#/Managed C++/Unmanaged C++, .NET Framework 2.0

Setup: A VS.NET 2005 solution which contains three projects. The top level (startup) project is a C# Windows Forms application that hosts an instance of the output of a second project, which is a managed C++ Windows Forms control that produces a DLL. This managed control is essentially a wrapper class that exposes functions found in the third project, an unmanaged C++ that produces a DLL. This third project, in turn, utilizes static libraries from third-party and in-house standard C++ projects. The two DLL projects are utilizing multi-threaded debug DLL runtime libraries. The managed control and top level winform project use the same strong-key for assembly signing, but I've been disabling digital signature verification for the two project outputs at the runtime to make testing a little easier.

All the projects compile and build without error. I can copy the resulting executable and all associated DLLs from the output directory to any other Windows XP computer and (provided the .NET framework 2.0 is installed) everything works as expected. However...

Problem: When I attempt to run the executable from any removable media, i.e. a USB jumpdrive or CD, a debug assertion is thrown in the CRT file access.c with the expression: ((amode & (~6)) == 0). When I debug this error, it turns out to be a FileLoadException which states that my C++ managed control DLL (or one of its dependencies) could not be loaded. The inner exception states that "one or more arguments are invalid" and reports an HRESULT of 0x80000003.

Question: Is this a permissions related problem? Why can I run my application off of a hard disk with no problems and then copy the entire directory structure *as-is* onto some form of removable media only to find myself faced with a FileLoadException?

Any help or insight into this problem would be greatly appreciated!