Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X
Hi all,
I have some basic idea on creating application using VB API, now I am trying to create a application using C#. Can somebody help me regarding procedure to start with like adding reference in visual studio, and connecting to the active creo session. I have gone through tkuse but I am no where.
Regards
Manjunath.S
Solved! Go to Solution.
Yes, of course. You can even combine VB.NET and C# ...
Hello Manjunath S
Creo API does not directly support C# but you can do by using dynamic libraries. You need to create your own dynamic library using Native language.
If you want to create a Creo Toolkit library, you need to create dll in C Program and import at runtime with your C# Project.
See this thread, how to import C++ dll in C# program
https://stackoverflow.com/questions/7232259/c-sharp-importing-c-dll
Parthiban Kannan how to add reference in Visual studio while using a c program. Also I need to have develop an application with user interface. Please provide if training material if available, except TKUSE.
Hello Manjunath S,
You cannot add reference like C# or Vb.net program. You've to use interop services & refer the dll at runtime
There is no need for creating C program. VB API is COM library, not .NET assembly, but you can use it as a reference in .NET application.
You have to follow the first steps described in the documentation:
Common Files\vbapi\vbapidoc\index.html, User's guide > Overview of the VB API > Visual Basic .NET Applications
You have register VB api by vb_api_register.bat and then you have to add the reference in Visual Studio. For C#, right click the References in Solution Explorer > your solution > your project and in the dialog that appear switch to COM tab - you will find there the library mentioned in the user's guide
You have to add then:
using pfcls;
and this is an example method for making connect to Creo:
public static void Connect(bool synchronous)
{
try
{
m_Connection = new CCpfcAsyncConnection().Connect(null, null, null, null);
m_Connected = true;
}
catch (Exception ex)
{
CheckReturnCode(-1, ProErrors.CONNECT);
}
}
Back in 2015, I used VBAPI with Vb.Net. Can we use C# for VBAPI as well?
Yes, of course. You can even combine VB.NET and C# ...
Hello PARHTIBAN_K
i know the link to stackoverflow, but i think the problem is that Manjunath_S and i need not only the call to a c function. If i create a menue and want to call a c# function from their. I think that is the main problem (for me).
Do you think we can create a small visual studio project that shows the using?
I think that all others were happy to have a little example.
Thanks 😉