I want to learn to write an OpenSTAAD code in Visual Studio 2023 C++. I followed the steps as listed in STAAD.Pro Help OpenSTAAD. The code given by Bentely is look like:
#import "C:\Program Files\Bentley\Engineering\STAAD.Pro CONNECT Edition\STAAD\StaadPro.dll" named_guidsusing namespace OpenSTAADUI;using namespace std;namespace OSApp = OpenSTAADUI; int main(){ OSApp::IOpenSTAADUIPtr OSAppPtr; try { CoInitialize(NULL); HRESULT hr = OSAppPtr.CreateInstance(__uuidof(OSApp::OpenSTAAD));
if (hr != S_OK) { printf("Unable to connect to STAAD.Pro application!\n"); return 1; }
hr = OSAppPtr.GetActiveObject(__uuidof(OSApp::OpenSTAAD)); if (hr != S_OK) { printf("Unable to connect to an active instance of STAAD.Pro application!\n"); return 1; }}catch (_com_error& e) { _bstr_t bstrDescription = e.Description(); printf("COM Error! %s\n", bstrDescription); }}
The problem is when reaching the Linking stage, an error occur about 'StaadPro.dll' saying that: "Error LNK1302 only support linking safe .netmodules; unable to link ijw/native .netmodule". I am grateful for any help I receive.
I found the solution by following exactly the steps in OS. Write an OpenSTAAD Program in C++ (bentley.com) by editing the project file and by adding manifest file.
Answer Verified By: Ahmed Shakir Hassan