C++ – access violation error when using map in dll


I tried to create a win32 dll using c++. It has a map declared globally. But when I try to access the map using the dll its giving a run time error that: WindowsError: exception: access violation reading 0x00000008. How to solve it?

Declaration: static map<int,urllib> url_container;

The urllib is a class.

Error occurance: url_container[ucid] = urllib();

The error occurs at the above point.

Best Solution

I assume urllib is a type or class and not a function?

It doesn't look like there's anything wrong with your code. In the debugger, what do you see on the call stack when the exception happens? It would be helpful to see exactly where it's running into the access violation.

Related Question