cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

Looking for some pointers on the C API

nborrerojr.
7-Bedrock

Looking for some pointers on the C API

I would like to start looking into integrating the API into some software I'm working on. Basically I am hoping someone can help me with using the sample code at https://support.ptc.com/appserver/cs/view/solution.jsp?n=CS161216. When I try to include mksapi.dll as a reference in my project, I get an error "A reference to 'mksapi.dll' could not be added." I don't have the Visual Studio integration setup but I was under the impression (maybe incorrectly) that this wouldn't be required. Has anyone encountered this before and found a solution?

errorMessage.jpg

1 ACCEPTED SOLUTION

Accepted Solutions

The source of my problem was what I defined in the app capabilities. This is something unique to WIndows RT apps. I had the Internet (Client) capability selected but I did not have Private Networks (Client & Server)selected. Because of this my app could not talk to the Integrity server but because of my unfamiliarity with the API, I had trouble tracking down the issue.

capabilities.jpg

Since Visual Studio 2013 Express isn't one of the versions supported for the Visual Studio Integration, I had to set it up a bit differently. Here's how:

  • Using 7zip, I extracted MKS.ManagedAPI.dll from the Integrity_VS_Integration.msi installer
  • I added MKS.ManagedAPI.dll as a reference to my project (Project > Add Reference > Browse)
  • I added the following dll's in my project as existing items (In Solution Explorer, Right click project >Add > Existing Item) because Visual Studio 2013 Express will not allow them to be added as references
    • apiblimp.dll
    • libeay32.dll
    • libxml2.dll
    • mksapi.dll
    • mksapi.lib
    • nspr4.dll
    • ssleay32.dll

addExisting.jpg

  • For each of the dll's (and lib), set Copy to Output property to Copy if newer

I was then able to use the sample code at: https://support.ptc.com/appserver/cs/view/solution.jsp?n=CS159452. The only edit that I had to make was to use APIFactory.CreateIntegrationPointinsted of APIFactory.CreateLocalIntegrationPoint since I am running this on a remote machine and not the server.

I haven't done too much yet so I don't know whether or not this is really a full integration. So far I have only used the sample code to get a reply. I am hopeful that this will be the correct solution though.

View solution in original post

15 REPLIES 15
KaelLizak
14-Alexandrite
(To:nborrerojr.)

Hello Nolin, We haven't recently had anything like that reported, and I have never run into that myself. Maybe someone else has run into something similar? Regards, Kael


Kind Regards,
Kael Lizak

Senior Technical Support Engineer
PTC Integrity Lifecycle Manager

Dependency Walker is telling me that the below dlls are not found (and mksapi.dll is dependent on them). I think this may be a Windows 8.1 thing. I'm trying to figure it out now.

API-MS-WIN-CORE-KERNEL32-PRIVATE-L1-1-1.DLL
API-MS-WIN-CORE-PRIVATEPROFILE-L1-1-1.DLL
API-MS-WIN-SERVICE-PRIVATE-L1-1-1.DLL
API-MS-WIN-CORE-SHUTDOWN-L1-1-1.DLL
EXT-MS-WIN-NTUSER-UICONTEXT-EXT-L1-1-0.DLL
IESHIMS.DLL

It looks like instead of adding the dll as a reference, you are just supposed to include it as an existing item. The Visual Studio Integration looks like it may be quite a bit simpler so I think I may just go that route instead.

Apparently the Visual Studio Integration only works with old versions of Visual Studio. Is there any plan to update this?

Here is where I am at after trying for a while to get this to work. To get the reference into my project, I extracted MKS.ManagedAPI.dll from the msi for Visual Studio Integration. This is because it cannot be installed with my version which is Visual Studio Express 2013. I added it as a reference. None of the other dlls could be added as they would all cause problems when it tried to compile. They all seem to rely on dlls for Windows desktop applications. I then included a bunch of the dlls from the client folder (including mksapi.dll) in the project instead of adding them as references. I have been working off of the sample code at https://support.ptc.com/appserver/cs/view/solution.jsp?n=CS159452. When I try to run the code, I get the below error when the cmd tries to execute at cr.Execute(cmd). Does anyone have any idea how to get around this issue? Is there any way to tell if I am even able to communicate with the server?

Source: MKS.ManagedAPI

Message: API communications error

Stack Trace:

at MKS.ManagedAPI.CmdRunner.RawExecute(Command cmd, ExecutionType execType)

at MKS.ManagedAPI.CmdRunner.Execute(Command cmd)

at MyApp.MyFunction()

One thing that may be relevant; I had to use APIFactory.CreateIntegrationPoint instead of CreateLocalIntegrationPoint because it would use 127.0.0.1 instead of the correct server address. This allowed me to directly specify the server address.

NeilSun
5-Regular Member
(To:nborrerojr.)

Normally "API communication error" means the application cannot talk to the Integrity server, there are two scenarios:

1. The PC running your application IS the Integrity server, then CreateLocalIntegrationPoint should be used

2. The Integrity server is somewhere else, then CreateIntegrationPoint should be used to give an IP address

Hope that helps.

The server is elsewhere so I am using CreateIntegrationPoint. Is there any way to tell whether or not it is able to connect successfully? I've tried running the server report for client connections and it's always shown 0 local api sessions and 0 web api sessions. If I connected successfully, would that show up as one of those?

After looking into it some more, I think I may have a network issue where I can't actually connect to the server. It may be some restriction is in place on my end. I'll post back after I find out more.

I think I got it figured out. I'll report back tomorrow with everything I did in case anyone else runs into this. Your comments here were helpful in tracking it down though.

NeilSun
5-Regular Member
(To:nborrerojr.)

Hi Nolin, please find mksapi.dll mksapi.lib mksapi64.lib under <integrity client installation path>\bin, then add them into your microsoft visual studio project as reference and dependency.

I have them all included by adding them with Right Click>Add>Existing Item but if I try to add mksapi.dll as a reference, I get the error in my original post.

Untitled.jpg

Correction: I get this error when I try to add mksapi.dll as a reference

error.jpg

NeilSun
5-Regular Member
(To:nborrerojr.)

My previous reply was for C API.

For C# API, MKS.ManagedAPI.dll from Integrity Visual Studio Integration is what you need, but unfortunately Microsoft Visual Studio 2013 was NOT tested.

And when I say "add reference" it didn't mean add the files as "Exsiting Item", it means:

How to: Add or Remove References By Using the Add Reference Dialog Box

http://msdn.microsoft.com/en-us/library/vstudio/wkze6zky(v=vs.120).aspx

Above document is from Microsoft MSDN website

NeilSun
5-Regular Member
(To:nborrerojr.)

Hi Nolin, I'm glad you figured it out. Is there anything can to be improved for PTC Document CS161216 and CS159452? Please feel free to let me know. Thanks.

I think both of those documents are OK. My project is just outside the scope of those documents. It may be worth clarifying the difference between CreateLocalIntegrationPoint and CreateIntegrationPoint but that's about it.

NeilSun
5-Regular Member
(To:nborrerojr.)

Thanks a lot for your feedback. I will leave the two documents as they are.

The difference between CreateLocalIntegrationPoint and CreateIntegrationPoint are documented in Integrity Integrations Builder Guide which could be downloaded by following document CS152080. Since you are currenlty working on Integrity development, I would recommand Integrations Builder Guide to you.

Hope it helps. And thanks a lot for sharing your experience. I'm sure it will help others.

The source of my problem was what I defined in the app capabilities. This is something unique to WIndows RT apps. I had the Internet (Client) capability selected but I did not have Private Networks (Client & Server)selected. Because of this my app could not talk to the Integrity server but because of my unfamiliarity with the API, I had trouble tracking down the issue.

capabilities.jpg

Since Visual Studio 2013 Express isn't one of the versions supported for the Visual Studio Integration, I had to set it up a bit differently. Here's how:

  • Using 7zip, I extracted MKS.ManagedAPI.dll from the Integrity_VS_Integration.msi installer
  • I added MKS.ManagedAPI.dll as a reference to my project (Project > Add Reference > Browse)
  • I added the following dll's in my project as existing items (In Solution Explorer, Right click project >Add > Existing Item) because Visual Studio 2013 Express will not allow them to be added as references
    • apiblimp.dll
    • libeay32.dll
    • libxml2.dll
    • mksapi.dll
    • mksapi.lib
    • nspr4.dll
    • ssleay32.dll

addExisting.jpg

  • For each of the dll's (and lib), set Copy to Output property to Copy if newer

I was then able to use the sample code at: https://support.ptc.com/appserver/cs/view/solution.jsp?n=CS159452. The only edit that I had to make was to use APIFactory.CreateIntegrationPointinsted of APIFactory.CreateLocalIntegrationPoint since I am running this on a remote machine and not the server.

I haven't done too much yet so I don't know whether or not this is really a full integration. So far I have only used the sample code to get a reply. I am hopeful that this will be the correct solution though.

Top Tags