Click here to Skip to main content
15,935,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear All,

In my WPF App, I need to refer/invoke the c++ class from a different module.,into the current project.

Assuming, I am working in a <<MySolution.sln>> which has numerous projects, and one handling wpf GUI(MyWPFproj.cproj) here, I need to refer a C++ class albeit in different module/project., viz., (MyCPPProj.cproj) how could it be addressed in wpf.

since I am from MFC, If we need to refer a differnt dll, in our exe we use the Load Library and GetProcAddress constructs in InitInstance().,

but how is the methodology of the same in wpf, I am using MyWPFBasic.xaml.cs
with following,

using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Input;
...

namespace Myproj.UI.Windows
{
public partial class MyProj:Windows
etc.,

I am using VS2008 IDE for Developing WPF Application using WinXP o/s,SP 1.

Thanks in Advance,

With Regards,
Samanth_90
Posted
Updated 11-Mar-12 20:30pm
v2

1 solution

Direct invocation between C++ classes and .NET is not supported, because layout of C++ classes is specific to the language and cannot be universally described as platform invoke.

Basically, you import only the static methods. You can wrap the functionality of the C++ class into a set of static methods, import them in .NET and wrap them in .NET class.

Then you have two options:



—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900