Some sample code for using C# with the ProjectWise SDK

I posted some parts of these two sample customizations recently, but to make things easier for those looking for the full Visual Studio Projects, you can download the code from GitHub.  First of all, you will need Dave Brumbaugh's MostOfDavesClasses, but I did include the source in the projects just to keep it simple.

https://github.com/DaveBrumbaugh/MostOfDavesClasses-CSharp-Wrappers-For-ProjectWise 

https://github.com/DanWilliamsAtBentleyDotCom/Sample-Login-CSharp-For-ProjectWise 

https://github.com/DanWilliamsAtBentleyDotCom/Sample-Calling-CSharp-Code-From-Mrr-File

I created the two samples using Visual Studio 2015, ProjectWise Explorer CONNECT Edition 10.00.03.167, and ProjectWise SDK 10.00.03.140.

I plan on creating additional samples for FAQ and as time permits.  Hopefully these samples help folks get past these two questions.

Parents
  • Was thrilled to find this code but am having problems getting the Sample-Calling-CSharp-Code-From-Mrr-File the unmanaged project to compile. It cannot find the Header files that come with sdk have tried everything  adding, headers to project properties to point to include directory. Using VS 2019 and Windows 10 SDK

  • I assume that you mean the header files that come with the ProjectWise SDK.  Assuming that you are using a CONNECT version of ProjectWise and the SDK (it is always helpful to mention versions of applications, SDK, OS, etc. to help those who may be able to help you).  On a 64-bit OS such as "Windows 10" x64, the SDK will install by default in C:\Program Files\Bentley\ProjectWise\SDK and the header files are under the "include" subdirectory.  

    For linking, you need to specify that the library files are in the "lib" subdirectory.  For customizations involving ProjectWise Explorer, which is a 32-bit application, you need to link to the libraries under the Win32 subfolder.  The default path to that location would be C:\Program Files\Bentley\ProjectWise\SDK\lib\Win32.

    My sample code uses macros to define these locations.  Take a look at the PowerShell script that I included with the "SampleLogin" code, named "SetSystemEnvVarsForPWSDK.ps1", which  defines these locations as Windows Environment variables.  You can run that PS script to setup the environmental variables that I used, just make sure that they "point" to the correct locations on your box.

    Here's what that PS script looks like:

    [Environment]::SetEnvironmentVariable("PWBinx86Dir", "C:\Program Files (x86)\Bentley\ProjectWise\bin\", "Machine")
    [Environment]::SetEnvironmentVariable("PWIncludeX86Dir", "C:\Program Files\Bentley\ProjectWise\SDK\include\", "Machine")
    [Environment]::SetEnvironmentVariable("PWLibx86Dir", "C:\Program Files\Bentley\ProjectWise\SDK\lib\Win32\", "Machine")
    [Environment]::SetEnvironmentVariable("PWRsrcx86Dir", "C:\Program Files (x86)\Bentley\ProjectWise\rsrc\", "Machine")
    [Environment]::SetEnvironmentVariable("PWSDKx86Dir", "C:\Program Files\Bentley\ProjectWise\SDK\", "Machine")
    
    [Environment]::SetEnvironmentVariable("PWBinx64Dir", "C:\Program Files\Bentley\ProjectWise\bin\", "Machine")
    [Environment]::SetEnvironmentVariable("PWIncludeX64Dir", "C:\Program Files\Bentley\ProjectWise\SDK\include\", "Machine")
    [Environment]::SetEnvironmentVariable("PWLibx64Dir", "C:\Program Files\Bentley\ProjectWise\SDK\lib\x64\", "Machine")
    [Environment]::SetEnvironmentVariable("PWRsrcx64Dir", "C:\Program Files\Bentley\ProjectWise\rsrc\", "Machine")
    [Environment]::SetEnvironmentVariable("PWSDKx64Dir", "C:\Program Files\Bentley\ProjectWise\SDK\", "Machine")
    
    [Environment]::SetEnvironmentVariable("PythonDir", "C:\DevTools\Python27", "Machine")
    

    HTHs

  • the dmawin.lib is located on my machine in:

    C:\Program Files (x86)\Bentley\ProjectWise\SDK\libx64
    C:\Program Files (x86)\Bentley\ProjectWise\SDK\libwin32

    Not sure where in project settings to place the mapping to "C:\Program Files (x86)\Bentley\ProjectWise\SDK\libwin32"

  • Was able to get everything to compile verified all the files in bin directory but menu just stays grayed out and I am out of things to try

  • Njarvis,

    Context is "everything" when debugging.  When/where exactly do you see this message?  When you build the project, or when you try to run it?

    Your Windows account may not have access to "open" that file.  It is common to set up Visual Studio to "run as Administrator" to get by most OS restrictions.  And I typically set all the folders and files under the ProjectWise folder to give my Windows account Full Access to avoid any restrictions accessing those files.  Not something you want to do for "typical" users, but makes life easier for me as a developer.

    If it isn't Windows security, then please post more context, and "pictures" really help!

  • The linker, for the unmanaged code.  (you have a typo in the path above)

    Don't forget to build unmanaged code for "Release" when you are ready to distribute your customization.

  • Screenshot would help.

    If you are using my sample code and .mrr file, then perhaps you don't have a document selected?

Reply Children
No Data