SDK environment sample does not appear to run in its $(Output) directory without the need of copying all the DLLs from the bin folder.
in this case, the resources are not shown in the login dialog, am I missing something?
Also in this case aaApi_Initialize(AAMODULE_TOOLS); returns false; // in CEnvironmentDlg::OnInitDialog()
aApi_GetLastErrorId() returns error code "140"
aaApi_GetMessageByErrorId(140) returns nothing.
My application is also returning 140 with flag AAMODULE_IDESKTOP, is this the missing resources?
You need to change the value for your working directory to be the ProjectWise "bin" directory -OR- copy your .exe file to that directory and run it from there.
As for why aaApi_Initialize() fails, I suspect that one or more of the PW DLLs are not loading because Windows doesn't know where they are.
This sample "works" on my box if I make the following change:
I have a bunch of Windows Environment variables, like "PWBinx86Dir", that I use to "point" to specific locations that you probably don't have on your box. It is OK to simply browse to the correct location.
Here's the result after making the change:
Dan WilliamsSolution ConsultantBentley Systems, IncorporatedPortland, OR, USA (Pacific Time UTC-08:00)
This won't work for me, I need to be able to run another directory. I copied all the DLLs from the bin folder to the .EXE folder. hopefully there is a way to do this, our application is huge, and we can't install it into Bentley directories
Have you tried putting the ProjectWise bin folder path in your Windows PATH environment variable so that Windows can find the DLLs?
Here's what I did. I added the bin path to my system PATH:
Putting it in the OS User's PATH would work as well. Then I started my Visual Studio session and put the working directory back to what it was:
Then I rebuilt the project and ran the debugger against the rebuilt application, and it ran on my box from the development folder:
See if this approach works for your needs.
Answer Verified By: Daniel Marcotte
Woohoo! that works great!
A couple of thoughts, I wonder how the autocad plug-in gets around this?
I suppose I just need to have my installer add to the PATH variable
Yes, you could have your installer add to the PATH variable, or you could do it in your application when you call aaApi_Initialize(). The "trick" would be to know where the PW "bin" location is. The way to do that is to look in the Windows Registry for the path.
You can see this approach in MostOfDavesClasses.cs found here: https://github.com/DaveBrumbaugh/MostOfDavesClasses-CSharp-Wrappers-For-ProjectWise
Look over the constructor for the PWWrapper class and the try/catch block around aaApi_Initialize() and look at the method ApendProjectWiseDllPathToEnvironmentPath() for the details.