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

Managed C++ / .NET Classes


Managed C++ / .NET Classes

While we're on the Visual Studio theme today...

Has anybody tried to use C# classes in their Pro/TOOLKIT application in DLL mode? I can do it in spawn mode (exe) but they don't work in DLL mode.

I try to make all of my dialog screens with the Pro/TOOLKIT UI and it works well for simple screens. Anything more complicated and I usually end up spawning another program for the dialog and then package up the results to return them to the main app. Since C# and managed C++ can talk to each other I figure there wouldn't be a need for this "package" step and I could directly use a C# class to offload some of the GUI work.

Has anybody had any luck with this?


RE: Managed C++ / .NET Classes

Have you successfully used the C# class in the Pro/TOOLKIT application?

Itry to call C# method in the Pro/TOOLKIT C++ application. It can be built successfully. However, the Pro/TOOLKIT DLL application cannot be loaded into Pro/ENGINEER.

To mix the C++ and C#, I use option /clr to compile the applicaiton. Maybe the issue is related to the Common Language Runtime.


Managed C++ / .NET Classes

Creating a Pro/TOOLKIT dll that contains managed C# code is not possible.
The reason is that the Pro/TOOLKIT dll runs within the xtop.exe process'
memory space. Since xtop.exe doesn't run on the CLR then your dll cannot
contain any managed code. However; you may be able to create an
asynchronous Pro/TOOLKIT application that contains managed code. I do
remember talking to John Sprang about this in the past and he has gotten
it to work. You can look up his contact information on the PTC/User
Portal site.

Patrick Williams
Sr. Systems Engineer II
Mechanical Engineering Solutions
Missile Systems
Raytheon Company

+1 520.545.6995 (business)
+1 520.545.6399 (fax)

6221 S Palo Verde Rd
Tucson, AZ 85706 USA

This message contains information that may be confidential and privileged.
Unless you are the addressee (or authorized to receive mail for the
addressee), you should not use, copy or disclose to anyone this message or
any information contained in this message. If you have received this
message in error, please so advise the sender by reply e-mail and delete
this message. Thank you for your cooperation.


RE: Managed C++ / .NET Classes

Patrick Williams,

Thanks very much for your help. We cannot directly call managed DLL from Pro/TOOLKIT code. However, I think we can expose managed DLL as COM, then call it in Pro/TOOLKIT. I will try it.




RE: Managed C++ / .NET Classes

I tested with a simple example, the steps are as following:

1. Write a C# application.

2. Register the C# application for use with COM.

3. Write Pro/TOOLKIT application, and call the COM method.

In MSDN, there is an article "How to call a managed DLL from native Visual C++ code in Visual Studio.NET or in Visual Studio 2005".