Hi there! I want to create a DLL for later use in an application.

The DLL must contain a vector.

(my ultimate goal is to create multiple instances of an object-class. Say: AllTeams>team1,team2, team3 etc. -- In Visual Basic (where I grew up with) this would be done by using a collection. I just mention this trying to explain my issue..)

I use Visual C++ 2008 Express.

My approach is:

1. I create a File>New Project -> Win32 > Win32Project->TypeLL + Export Symbols ( I named
all this StaticLD_2.sln

2. In Project Settings under StaticLD_2 Properties > C/C++>Extended>Calling COnvention I place __stdcall (/Gz) (insted of /Gd) ... doing try and error to prevent a metadata issue..

3. I add minor code to the automatically generated code by the wizard. Under TODO you will now find:
int MyVar;
vector<int> MyVect;
Entire code, see below:

4. StaticLD_2.h:

#define STATICLD_2_API __declspec(dllexport)
#define STATICLD_2_API __declspec(dllimport)

#include <vector>
using namespace std;

// Diese Klasse wird aus StaticLD_2.dll exportiert.
class STATICLD_2_API CStaticLD_2
// TODO: Hier die Methoden hinzufügen.
int MyVar;
vector<int> MyVect;


extern STATICLD_2_API int nStaticLD_2;

extern STATICLD_2_API int fnStaticLD_2(int Multiplyer);

5. The above copiles well and you wned up with StaticLD_2.DLL and *.LIB.

6. I now create a new console project to test the DLL. I also copy the dll and lib created in step 5 into the project folder of the new application project. The new project is called StaticLD_App_2.sln

7. StaticLD_App_2.cpp :

#include "stdafx.h"
#include "D:\rc_Sept07\CPP_Express\tr\StaticLD_2\StaticLD_2\StaticLD_2.h"

int _tmain(int argc, _TCHAR* argv[])
int fortytwo=nStaticLD_2;
int EightyFour=fnStaticLD_2(2);

CStaticLD_2 MyClass;

int MyItem=111;

return 0;

8. Here comes the PROBLEM:
When running the code using Debugger, it copiles will, I run into an error when approaching line marked with ***:
int MyItem=111;
*** MyClass.MyVect.push_back(MyItem);

The error box is Titled with: "Debug Assertion failed"

9. From what I vaguely learned : using vectors in a DLL is tricky. My know is too rudimentary to understand the reasons so I have no ide ahow to overcome this issue.

10. Remember my real goal: I want to create a collection structure. I try to do this using a vector. Finally, the vectors will not be defined through vector<int> but rather throu vector<MyObectClass>. However, I must undertand doing it with integers first.

11. Can someone help me get things right?

12. I attach the code. You may need to adjust the path of the include statment in the application project.