How to Call C# DLL in VC++ win32?
-
I am working in (Windows Presentation Foundation)WPF with C# environment. I have created simple DLL for C# with WPF. but how to call C# DLL from VC++ win32?. Following code of DLL:
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;namespace Test
{
/// <summary>
/// Interaction logic for UserControl1.xaml
/// </summary>
public partial class UserControl1 : UserControl
{
public UserControl1()
{
InitializeComponent();
}private void button1\_Click(object sender, RoutedEventArgs e) { textBox1.Text = "Welcome to Tessolve"; } }
}
Actually how to call C# dll function in Vc++ environment? Please share ur ideas or urls Regards, M.Mathivanan
-
I am working in (Windows Presentation Foundation)WPF with C# environment. I have created simple DLL for C# with WPF. but how to call C# DLL from VC++ win32?. Following code of DLL:
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;namespace Test
{
/// <summary>
/// Interaction logic for UserControl1.xaml
/// </summary>
public partial class UserControl1 : UserControl
{
public UserControl1()
{
InitializeComponent();
}private void button1\_Click(object sender, RoutedEventArgs e) { textBox1.Text = "Welcome to Tessolve"; } }
}
Actually how to call C# dll function in Vc++ environment? Please share ur ideas or urls Regards, M.Mathivanan
-
I am working in (Windows Presentation Foundation)WPF with C# environment. I have created simple DLL for C# with WPF. but how to call C# DLL from VC++ win32?. Following code of DLL:
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;namespace Test
{
/// <summary>
/// Interaction logic for UserControl1.xaml
/// </summary>
public partial class UserControl1 : UserControl
{
public UserControl1()
{
InitializeComponent();
}private void button1\_Click(object sender, RoutedEventArgs e) { textBox1.Text = "Welcome to Tessolve"; } }
}
Actually how to call C# dll function in Vc++ environment? Please share ur ideas or urls Regards, M.Mathivanan
-
I am working in (Windows Presentation Foundation)WPF with C# environment. I have created simple DLL for C# with WPF. but how to call C# DLL from VC++ win32?. Following code of DLL:
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;namespace Test
{
/// <summary>
/// Interaction logic for UserControl1.xaml
/// </summary>
public partial class UserControl1 : UserControl
{
public UserControl1()
{
InitializeComponent();
}private void button1\_Click(object sender, RoutedEventArgs e) { textBox1.Text = "Welcome to Tessolve"; } }
}
Actually how to call C# dll function in Vc++ environment? Please share ur ideas or urls Regards, M.Mathivanan
There is another trick. mscorlib.dll itself is also a COM dll, i.e. you can instantiate a COM object with that. And then you can load your .NET dll via that object. I do not remember all the details, I guess following article could help you: Creating a host application for the .NET Common Language Runtime.[^]
-
I am working in (Windows Presentation Foundation)WPF with C# environment. I have created simple DLL for C# with WPF. but how to call C# DLL from VC++ win32?. Following code of DLL:
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;namespace Test
{
/// <summary>
/// Interaction logic for UserControl1.xaml
/// </summary>
public partial class UserControl1 : UserControl
{
public UserControl1()
{
InitializeComponent();
}private void button1\_Click(object sender, RoutedEventArgs e) { textBox1.Text = "Welcome to Tessolve"; } }
}
Actually how to call C# dll function in Vc++ environment? Please share ur ideas or urls Regards, M.Mathivanan
One simple solution is to create a CLI/Interop DLL compiled with /clr, this DLL can export standard C function, which the C++ code can call. When implementing the standard C functions in the CLI/Interop DLL , then one is able to call standard .NET code, and it is possible for the CLI/Interop DLL to have references to other standard .NET assemblies. This example hosts a WinForms control in a MFC application, but one could just aswell host a WPF control: WinFormIntegration Sample: Demonstrates Hosting a WinForms User Control in an MFC Application [^]
modified on Friday, February 25, 2011 10:47 AM