Streaming local storage with __declspec (thread) error in C ++ / CLI

I am working on a project in which we mix .NET code and native C ++ code using the C ++ / CLI layer. In this solution, I want to use Thread Local Storage through the __declspec (thread) declaration:

__declspec(thread) int lastId = 0;

However, when I access the variable for the first time, I get a NullReferenceException. More precisely, the declaration is executed in the ref class (the .NET class implemented in C ++ / CLI).

I already read something about __declspec (thread) not working with delayed loading of DLLs. Am I using a delayed load DLL if I am using .NET?

+5
source share
2 answers

, CLA __declspec (thread) .

, .net- , , API , t .

, API .

, . , .

: ThreadStatic TLS, performance. ASP.NET, TLS.

+6

All Articles