Recently i am trying out the SMX connection of WinAC ODK to see if i can use this for dataexchange between our software and the softplc. The (c++?) examples are working perfectly, however whenever i try to integrate the library in our software i run into troubles with the creating the connection (with the use of function S7SMX_Open), that is as a return value i always get 'S7SMX_ERR_NO_CONTROLLER'. I use the next code :
// Open SMX connection
[DllImport("S7smxx.dll", EntryPoint = "?S7SMX_Open@@YAHKPBDPAPAX@Z", CharSet = ::CharSet::Auto)]
extern "C" S7SMX_ERROR S7SMX_Open(unsigned long dwFlags, [MarshalAs(UnmanagedType::LPStr)] String^ pDeviceName, void* phHandle);
//Open the connection
herr = S7SMX_Open(S7SMX_OPEN_MODE_WRITE, "WinLC RTX", &handle);
I found out that the difference between my project and the vs2008 c++ example projects is the use of common language runtime which is disabled in the examples.
f i enable this in the example projects (for example SMX_DataMemCopy) i run into the same problem, so my best guess here is that there is a problem with the marshalling or the String^ declaration.
Does anyone have any suggestions here, or is there an example of a CLI / C++ project with the function S7SMX_Open used properly?