I am trying to create a dll project using VS2005 (C++.NET). It is going to be used to access a database to store records w/o having to know how to actually create records (i.e. just pass info, and the dll classes will create a row in db).
I want to be able to use a String as a pass parameter but I am getting the following error:
""__declspec(dllexport) cannot be applied to a function with the __clrcall calling convention"
I have read some stuff on /clr option, managed and unmanaged stuff but its not very clear. I have also tried to create the project as a Win32 dll and as a CLR dll. What is the proper way to create a dll project that can accept the String type as a pass parameter (and return a String if necessary would also be nice).
Here is what I have so far. Obviously it doesn't actually insert anything into the db yet, just want to get the basics going first.
myApp.h:
#include <stdexcept> #using "system.dll" #include <string> using namespace std; using namespace System; namespace myAppClass { class myApp { public: //Returns info msg static __declspec(dllexport) int InsertMsg(String^ myTable); }; }
myApp.cpp:
#include "myApp.h" #include <stdexcept> #using "system.dll" #include <string> using namespace std; using namespace System; namespace myAppClass { int myApp::InsertMsg(String^ myTable) { if (myTable == "") { throw new invalid_argument("Table name cannot be blank!"); } return 0; } }