DllImport Attempted to read or write protected memory

lixinwin2003 2013-05-10 09:28:02
int ReadCard(char *room, char *gate,char *stime, char *guestname, char *guestid, char *track1, char *track2, long *cardno, int *st);
这是dll里的原函数
其中:room、gate、stime、guestname、guestid、track1、track2、cardno、st为输出参数
gate、Guestname 、Guestid 、track1 、track2 可以为null
翻译成C#的代码:
int ReadCard(ref string room, string gate, ref string stime,
ref string guestname, ref string guestid, string track1, string track2,
ref int cardno, ref int st);


这样写报错哟,你帮我看看!!
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
试图读取或写入受保护的内存。这往往是一个迹象表明其他内存已损坏。
...全文
252 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
lixinwin2003 2013-05-13
  • 打赏
  • 举报
回复
问题已经自己解决,这里数据类型错误,用StringBuilder,去ref,就可以!!都没有人回我!
lixinwin2003 2013-05-10
  • 打赏
  • 举报
回复
调用代码: string room = ""; //String gate = null; string stime = ""; //string guestname = null; string guestid = ""; //String track1 = null; //String track2 = null; int cardno = 0; int st = 1; int restul = adelMain.ReadCard(ref room, null, ref stime, null, ref guestid, null, null, ref cardno, ref st); if (restul == 0) { MessageBox.Show("成功!"); } else { MessageBox.Show("失败!" + restul); } 原型: [DllImport("MainDll.dll")] public static extern int ReadCard(ref string room, string gate, ref string stime, string guestname, ref string guestid, string track1, string track2, ref int cardno, ref int st);
源码下载地址: https://pan.quark.cn/s/40677b766bda "ContextCapture 倾斜摄影快速、创新及全面空三建模与单机集群硬件部署方案2018" 此资源聚焦于倾斜摄影(ContextCapture)空三建模及单机集群硬件部署方案,致力于为用户呈现最快、最优成本效益的台式工作站、移动工作站、并行集群的多样化部署选择。以下是该资源的详细知识点概述: 一、相关设备型号说明 * UltraLAB 是西安坤隆计算机科技有限公司推出的专属图形工作站品牌,具备三大卓越优势:顶尖的计算硬件架构、精准的行业应用定制服务、专业的硬件系统优化工艺。 二、硬件部署方案 * 台式工作站部署建议:设备特色在于当前市场上最快的台式计算架构,适用于办公场景下,部门层级常规的倾斜摄影空三处理、三维建模。 * 便携式工作站部署建议:设备特色在于当前市场上最快的移动计算架构,适用于移动倾斜摄影的空三处理、三维建模工作站。 * 大数据量处理工作站推荐:设备特色在于极限自动超频加速与16个并行存储构造,具备空三处理和三维建模最强的计算性能及海量高速并行存储性能。 * 多设备并行计算集群部署建议:针对海量图像数据计算产生的巨大需求,单机计算能力处理时间过长,效率不高,通过多台机器并行集群,进行空三处理、三维建模,显著减少处理时间。 三、部署方案深入解析 * 2.1 倾斜摄影建模(台式工作站)部署方案:设备特色在于最高的计算处理能力~6核5.2GHz,内存最大配置可达64GB,配备最新图灵架构的RTX显卡,相比市场其他品牌机器(单CPU、双Xeon处理器)更快、更具成本效益。 * 2.2 倾斜摄影建模(移动便携式工作站)硬件部署方案:设备特色在于最高的计算处理能力~6...

62,271

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧