VS2010 生成的托管C++DLL,byte* 对应C#啥

cow8063 2017-11-03 11:36:06
C++里面的其实是
explain_des(unsigned char *uartbuf_rx, unsigned char *buf_out, int len)
生成托管的DLL时候引用到C#项目,变成 了
explain_des(byte* uartbuf_rx, byte* buf_out, int len);
于是调用不知啥 调用
byte[] xx = new byte[];
IntPtr y = BytesToIntptr(xx);

IntPtr[] by = new IntPtr[1024];
byte[] xxx = new byte[1024];
myDES xxe = new myDES();
xxe.explain_des(y, by, xx.Length);

byte[],IntPtr都不行,都 提示无法转换成byte*
...全文
223 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
Demons1874 2017-11-03
  • 打赏
  • 举报
回复
byte* 是不安全代码,在项目属性勾上使用不安全代码,然后 unsafe { fixed (byte* uartbuf_rx = byte[]) fixed (byte* buf_out = byte[]) { xxe.explain_des(uartbuf_rx, buf_out, xx.Length); } }

111,098

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

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