Environmental VS2010
DllDemo.h // #pragma Once the using the System namespace; namespace DllDemo { public class MyValue REF { // the TODO: such a method is here added. value int; public: MyValue () { value = 123456789; } public: int PRINTVALUE () { return value; } }; }
using System; using System.Collections.Generic; using System.Linq; 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; using System.Runtime.InteropServices; using DllDemo; namespace WXDWXT_WPF { /// <summary> /// MainWindow.xaml 的交互逻辑 /// </summary> public partial class MainWindow : Window { MyValue myv1; public MainWindow() { InitializeComponent(); myv1 = new MyValue(); } private void button1_Click(object sender, RoutedEventArgs e) { MessageBox.Show("" + myv1.printValue()); } } }