Hi all, i am a new developer for PW, I want to use C# to call PW api, i have no ideal what dll i should reference in my C# project, so if anybody can help
send me an C# sample, to show the login dialog, or call some other apis.
For your specific question:
If you need to log into ProjectWise from your code call aaApi_LoginDlgExt() after calling aaApi_Initialize().
At this time ProjectWise does not have a Microsoft .NET managed API available. We have filed a change request with development for consideration and addition to ProjectWise in a future release. Linked are a couple unsupported C# projects that may be of some help. Below is some information and references I have put together on this topic that may be of some further assistance.
Accessing the ProjectWise API using Microsoft .NET
At this time ProjectWise Explorer customizations are only supported through a C-style ProjectWise application programming interface (API). Customizations should primarily be created using Microsoft Visual C for use directly in conjunction with ProjectWise Explorer using the ProjectWise native unmanaged code libraries currently available.
Once the C-style code is functioning properly within the ProjectWise Explorer environment as a customization; methods from your code in library (.dll) form could export “simple” wrapper functions and data types to be referenced and invoked by .NET based languages. No pointers should ever be passed from managed to unmanaged code or from one runtime to another for allocation or freeing; since that behavior is undefined and can easily destabilize your production environment; causing application exceptions/crashes.
Bentley ProjectWise senior developers have made similar recommendations on this topic on the BE Communities.
"Projectwise API and C#"
Bentley Technical Support Group has filed a change request (CR 155117) requesting a ProjectWise .NET accessible API to be made available in a future release.
Linked are a couple C# code samples that perform ProjectWise related operations from .NET. There is no guarantee on the state of these samples and as previously mentioned these samples are an unsupported effort at this time. Your best path forward is to create a C-style .dll and DllImport it to ensure your functionality is executed in a consistent manner and can be readily debugged in Visual Studio as a native code application.
You may want to consider using the Bentley ProjectWise Programming Forum on the BE Communities. It is a good resource to search and post ProjectWise programming issues to. When posting new issues to the BE Community your issues can be replied to by Bentley technical support colleagues (including myself), Bentley development and consultants, and other 3rd party developers and community members having similar interests and ProjectWise API experience and knowledge to share. Once an issue posted some additional benefits are that your question could have one or more accepted solutions (choices), it could be used for reference in the future by others to search, learn, and re-use. Since the BE Communities are monitored 24x7 some issues could potentially be resolved even after you have left for the day.
Here are a few related links on BE Communities on this topic that may provide some additional insight or help.
ProjectWise SDK from .NET (CSharp)
Bentley ProjectWise Programming Forum
ProjectWise API access with C# (Wiki)
ProjectWise SDK .NET Overload
Using <DllImport("dmsgen.dll")> _ with projectwise dll's
Can't call DLL function that makes ProjectWise API calls
SDK Document Creation, with environment
ProjectWise SDK from .NET (VB.NET)
VB.NET AutoCAD using PW API
ProjectWise SDK from MicroStation VBA (VBA/MVBA)
A MicroStation VBA Example With Bentley ProjectWise
Attached: ProjectWiseCSharpSamples.zip (PWExcelTest, PWGetAttributes, and some COM samples)
Answer Verified By: ware my
thanks Robert for your help, it did helps me a lot, i am now can run your example code and luanch the login dialog.
it is pretty exciting for me to see the dialog, thanks again.
I am run the PWCOMClass2 example, and my next quesion is how i can get which dll should be imported when i read the SDK help document, i can check in the sdk document there is a api named " aaApi_LoginDlg ", but i don't know which dll export this api, is there any way that i can get the dll name from any document? otherwise i have to use some dll check tool to see which dll export the api.
again thanks for your help and any help from the Technical support group.
Rick, being a new user to these forums please consider the guidelines below to help keep the quality of our forums high.
Bentley Be Communities - site help and product mappings
Be Communities - READ FIRST: MicroStation Programming forum best practices
Be Communities - Text Editor Help/Tips
Be Communities - Product Community Mappings
To answer your most recent question:
The most common libraries to include in client projects are: dmawin;dmscli;dmsgen;dmactrl. If you need to locate functions available in other libraries you can use the Microsoft "dumpbin.exe" approach I recommended in the thread below.
"trouble with aaApi_Login(), and how do I find the correct DLL for declaring a function?" https://communities.bentley.com/products/programming/projectwise_programming/f/342995/p/90780/259520.aspx#259520
Got it, and thanks again for all the information.