DLL是另一家公司的 用什么开发的不清楚第1个问题:尝试读取或写入受保护的内存代码如下:private void button1_Click(object sender, EventArgs e)
        {
            txtResult.Text = "";
            txtOut.Text = "";            string strIn = txtIn.Text;            StringBuilder strOut = new StringBuilder(1024);                        int result = Test1.YbjkInterface(strIn,ref strOut);            txtResult.Text = result.ToString();            txtOut.Text = strOut.ToString();            MessageBox.Show("执行完毕");        }        class Test1
        {
            [DllImport("hisYbjkInterface.dll")]
            
            public static extern int YbjkInterface(string strIn, ref StringBuilder strOut);
        }
搜了一下 改成这样 不再报内存错误private void button1_Click(object sender, EventArgs e)
        {
            txtResult.Text = "";
            txtOut.Text = "";            string strIn = txtIn.Text;            StringBuilder strOut = new StringBuilder(1024);                        int result = Test1.YbjkInterface(strIn, strOut);            txtResult.Text = result.ToString();            txtOut.Text = strOut.ToString();            MessageBox.Show("执行完毕");        }        class Test1
        {          
            [DllImport("hisYbjkInterface.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]            public static extern int YbjkInterface(string strIn, [MarshalAs(UnmanagedType.LPStr)]StringBuilder strOut);
        }
但又有另一个问题 如果传入错误的参数 DLL会有出参提示 格式不对 但如果是正确的参数 会提示
Access violation at address 09303B19. Write of address 09303B19我用别的开发工具 比如VFP 试了一下是可以调用成功的