﻿Question:
In "MS Visual Studio 2010" and .NET 4.0 Framework my application crashes when making call to "NIST library" DLL. What should I do?

Answer:
Important notes for using "NIST library" in "MS Visual Studio 2010".

1. "NIST library" is a native 64-bit Windows DLL.
In IDE of MS "Visual Studio 2010" you need to set "targeted platform" as "x64".

2. You need to "run as administrator" the IDE compiler and application.

3. When trying to run application in "MS Visual Studio 2010" you might receive the error message
"Attempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang".

The solution:
In IDE go to the menu "Debug", then go to the menu "Exceptions", and then expand "Managed Debugging Assistants", and uncheck "Thrown" for "LoaderLock".


4. If application is built targeting version 4.0 of the .NET Framework, the call to the unmanaged DLL will always fail with a StackOverflowException under the debugger.
If application is built targeting version 3.5 (or lower) of the .NET Framework, it works correctly.

The solution:
As a workaround solution is to run the application in IDE without debugger (Ctrl-F5), then application will work correctly. Also you can build application and run it outside of IDE.
This is a known bug of "MS VS2010 compiler". Please check out for updates and hotfixes from Microsoft for the latest solution to this problem. 

5. Please also read:
http://www.cognaxon.com/index.php?page=wsqlib_NETnotes
