Excel-DNA/IntelliSense

Managed Debugging Assistant 'LoaderLock'

mvorisek opened this issue · 5 comments

The link is not so helpful for what we're doing.
We are trying to monitor the process to see when libraries are loaded or unloaded, in order to know when an add-in is loaded into Excel. To do this we use a Windows API called LdrRegisterDllNotification. Since this causes our managed code to run in a potentially dangerous context, Visual Studio is showing the warning. I guess one could create a native code mechanism to track and notify, but would be a fair amount of complication just to avoid the debugging assistant. Better would be a way to run some code (e.g. set an environment variable or registry setting) that disables this particular MDA for this process. Not sure if you know of a way to do that . . .

Enviroment var. https://docs.microsoft.com/en-us/dotnet/framework/debug-trace-profile/diagnosing-errors-with-managed-debugging-assistants#environment-variable
or according to this https://github.com/dotnet/docs/blob/master/docs/framework/debug-trace-profile/contextswitchdeadlock-mda.md doc a https://docs.microsoft.com/en-us/dotnet/api/system.mtathreadattribute MTAThreadAttribute attribute should supress the warning.

But the enviroment var. needs to be set before the app. is started and the MTAThreadAttribute attribute can be set only on Main method. Is that possible when this lib. is used as .dll?

@mvorisek - Can you provide an example where did you applied the MTAThreadAttribute ? I do have AutoOpen() method.

@mvorisek - Can you provide an example where did you applied the MTAThreadAttribute ? I do have AutoOpen() method.

Thank you for opening this topic, but I am sorry, this issue is 3 years old and I am now working on different projects, thus I cannot provide an example. Hope the description is enough.