运行设备控制程序报错 CA1303和CA2101
报错信息:
错误 CA1303 方法“bool Program.Checks(int _rc, byte _ReType)”将文本字符串作为“void Console.WriteLine(string value)”的调用的参数“value”进行传递。改为从资源表检索以下字符串:“Negative response”。
错误 CA2101 指定对 P/Invoke 字符串参数进行封送处理
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.IO;
using System.Timers;
using System.Threading;
namespace CardDispenser
{
unsafe static class Program
{
private static bool Checks(int _rc, byte _ReType)
{
bool checksResult;
checksResult = false;
if (_rc == 0)
{
if (_ReType == 0x50)
{
Console.WriteLine("Positive response");
checksResult = true;
}
if (_ReType == 0x4e)
{
Console.WriteLine("Negative response");
// Command sending failed or command execution failed
//Console.WriteLine(ResErrMsg(St1, St2));
}
}
else
{
Console.WriteLine("Communication error");
}
return checksResult;
}
[DllImport("AAA.dll", CharSet = CharSet.Ansi)]
private static extern int CommClose(IntPtr ComHandle);
static void Main()
{
...
}
}
}