C# Winform应用程序与C#写的DLL间结构的传递 用C#写了个WINFORM应用程序,用C#写了个DLL,现在需要往DLL里传递结构,怎么弄?请各位大侠帮帮忙! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 把“结构”定义在dll里面,winform去调用它就行了。 c#winform: StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public class mn { [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 40)] public string a; }C# dll: [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public class mn { [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 40)] public String a; } public static string GetData(ref mn m_gb1) { try { return "a"; } catch { return ""; } }在C#winform中传递结构: mn k; k.a = "aaa"; Cems_Deal.Cems_Deal a = new Cems_Deal.Cems_Deal(); string str=a.GetData(k);错误提示:错误 1 与“Cems_Deal.Cems_Deal.GetData(ref Cems_Deal.Cems_Deal.mn)”最匹配的重载方法具有一些无效参数 D:\Program\StepRtu2010\StepRtu2010\DealDataThread.cs错误 2 参数“1”: 无法从“StepRtu2010.PublicVar.mn”转换为“ref Cems_Deal.Cems_Deal.mn” D:\Program\StepRtu2010\StepRtu2010\DealDataThread.cs 选择性读取txt里面的数据 如何做一个类似监视窗口的小东西(100分) 关于反汇编程序的问题 C# mschart 大家帮帮忙~求上个月的今天 动态控件问题 怎样在安装过程中,把程序加入启动组? 高手帮我看看错在那里? 【【【【【【【【 C#怎么检测Img的链接? 】】】】】】】 C#操作word文档,RPC 服务器不可用。 (异常来自 HRESULT:0x800706BA) 用C#写一个画图的类,不能重绘。。。求救!!! Remoting IPC 抛出异常【 端口忙: 所有的管道范例都在使用中。】
public class mn
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 40)]
public string a;
}
C# dll:
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public class mn
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 40)]
public String a;
}
public static string GetData(ref mn m_gb1)
{
try
{
return "a";
}
catch
{
return "";
}
}在C#winform中传递结构:
mn k;
k.a = "aaa";
Cems_Deal.Cems_Deal a = new Cems_Deal.Cems_Deal();
string str=a.GetData(k);
错误提示:
错误 1 与“Cems_Deal.Cems_Deal.GetData(ref Cems_Deal.Cems_Deal.mn)”最匹配的重载方法具有一些无效参数 D:\Program\StepRtu2010\StepRtu2010\DealDataThread.cs
错误 2 参数“1”: 无法从“StepRtu2010.PublicVar.mn”转换为“ref Cems_Deal.Cems_Deal.mn” D:\Program\StepRtu2010\StepRtu2010\DealDataThread.cs