facing issue with Projectwise aaApi_GetDocumentStringProperty(DOC_PROP_FILENAME,i) using C#

Hi

I am using Projectwise APIs in C# using DLLImports, all my other APIs work without any failure. But when I tried to aaApi_GetDocumentStringProperty(DOC_PROP_FILENAME,i) API  my program terminated without giving any error. Can anyone help me to figure out this.

 

My code,

[DllImport(@"C:\Program Files (x86)\Bentley\ProjectWise\Bin\dmscli.dll", CharSet = CharSet.Unicode, SetLastError = true)]   

public static extern string aaApi_GetDocumentStringProperty(int lPropertyId,int lIndex);

function()

{

 int Count = PWAPIs.aaApi_SelectDocumentsByProjectId(project_no);

for (i = 0; i < Count; i++)

{

string fileName = PWAPIs.aaApi_GetDocumentStringProperty(DOC_PROP_FILENAME, i);

...

..

}

}

Regards,

Atul Dusane

 

Parents
  • The API call returns a pointer, so you'll need something like this:

    [DllImport("dmscli.dll", CharSet = CharSet.Unicode)]
    private static extern IntPtr aaApi_GetDocumentStringProperty(DocumentProperty PropertyId, int Index);

    Then marshal it to a string with something like this:

    string fileName = Marshal.PtrToStringUni(aaApi_GetDocumentStringProperty(PropertyId, Index));

    Answer Verified By: Atul 

Reply
  • The API call returns a pointer, so you'll need something like this:

    [DllImport("dmscli.dll", CharSet = CharSet.Unicode)]
    private static extern IntPtr aaApi_GetDocumentStringProperty(DocumentProperty PropertyId, int Index);

    Then marshal it to a string with something like this:

    string fileName = Marshal.PtrToStringUni(aaApi_GetDocumentStringProperty(PropertyId, Index));

    Answer Verified By: Atul 

Children