我在c ++中创建了一个DLL,其中包含一个只返回字符串“Hello”的函数。但是,当我在c#应用程序中导入此dll并尝试在标签中显示此输出时,它不会显示任何内容
这是我的代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void close_Click(object sender, EventArgs e)
{
Close();
}
[DllImport("Dll1.dll", EntryPoint = "Print_Hello", CallingConvention = CallingConvention.Cdecl)]
public static extern string Print_Hello();
private void click_Click(object sender, EventArgs e)
{
string s = Print_Hello();
Hllolbl.Text = s;
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}