【新手100分】C#调用DLL失败 - 报System.AccessViolationException 尝试读取或写入受保护的内存。这通常指示其它内存已损坏 [问题点数:100分,结帖人KongNan]

Bbs1
本版专家分:6
结帖率 100%
Bbs9
本版专家分:52112
Blank
黄花 2016年4月 .NET技术大版内专家分月排行榜第二
2016年2月 .NET技术大版内专家分月排行榜第二
Blank
蓝花 2017年3月 .NET技术大版内专家分月排行榜第三
2017年2月 .NET技术大版内专家分月排行榜第三
2016年9月 .NET技术大版内专家分月排行榜第三
2016年8月 .NET技术大版内专家分月排行榜第三
2016年7月 .NET技术大版内专家分月排行榜第三
2016年3月 .NET技术大版内专家分月排行榜第三
2016年1月 .NET技术大版内专家分月排行榜第三
2015年12月 .NET技术大版内专家分月排行榜第三
2015年11月 .NET技术大版内专家分月排行榜第三
Bbs12
本版专家分:409722
版主
Blank
名人 2014年 荣获名人称号
2013年 荣获名人称号
2012年 荣获名人称号
Blank
状元 2013年 总版技术专家分年内排行榜第一
Blank
探花 2014年 总版技术专家分年内排行榜第三
Blank
进士 2012年 总版技术专家分年内排行榜第四
Bbs1
本版专家分:6
Bbs1
本版专家分:6
Bbs1
本版专家分:6
Bbs1
本版专家分:0
C#尝试读取写入保护内存。这通常指示其他内存已损坏
C#<em>调用</em>外部DLL,把带有中文字符的文件路径传递给DLL变量时,出现“<em>尝试</em><em>读取</em>或<em>写入</em>受<em>保护</em>的<em>内存</em>。这<em>通常</em><em>指示</em>其他<em>内存</em><em>已损坏</em>。”错误。 n 如图:文件路径: n错误代码如下://定义赋值IDL下的变量n oComIDL.SetIDLVariable("infile", inFilePath); //输入文件inFilePath赋值给IDL中的变量infile经过调试发现原因是:该文件路径(字符串
关于C#调用C++dll文件的异常处理 ——“尝试读取写入保护内存。这通常指示其他内存已损坏。”
【原因1】nC++和C#的参数类型对应问题(详细内容参考链接:https://jljlpch.iteye.com/blog/520509)n【举例】n如C++:nbool __declspec(<em>dll</em>import) getImage(unsigned char** ppImage, int&amp;amp;amp; nWidth, int&amp;amp;amp; nHeight);n对应C#成:n[DllImport(“tes...
窗体控件的System.AccessViolationException: 尝试读取写入保护内存解决方案。
前段时间维护公司一个小程序时,在窗体添加自动下拉滚动条时,出了这个异常。System.AccessViolationException: <em>尝试</em><em>读取</em>或<em>写入</em>受<em>保护</em>的<em>内存</em>解决方案。 static class Programn {nn private static Form1 M_WinForm;nn /// n /// 应用程序的主入口点。n
GetPrivateProfileString函数 出现错误尝试读取写入保护内存。这通常指示其他内存已损坏
错误如下: n n原因是:StringBuilder必须先初始化才能使用。 n将 StringBuilder temp =null 改为 StringBuilder temp = new StringBuilder() 问题解决
C# 尝试读取写入保护内存,这通常指示其他内存已损坏。System.AccessViolationException
遇到这个问题查了很久, 大多数说是<em>调用</em>第三方<em>dll</em>问题,这个问题一直到最后才发现 C#遇到这种问题的亲们, 看一下你们是否运用到了unsafe模式下的非托管<em>内存</em>,是否有两个线程共同访问一个公共对象的情况。 在unsafe模式操作非托管<em>内存</em>的情况下,第一个线程使用完这个对象就把这个对象清空,这时候第二个线程正在使用这个对象,就会因为<em>内存</em>中找不到这个<em>内存</em>区域而报错...
c#开发中遇到System.AccessViolationException
笔者在使用vs2013开发<em>c#</em>时突然遇到“System.AccessViolationException”这个类型的错误,可是将同样的代码,放到其他人的计算机上却奇迹的可以运行过去,笔者编查网络,都说是代码错误,可是要真是代码有问题,怎么可以在其他人的计算机上可以运行呢?于是笔者不在差错,看看是不是系统设定出了问题,果然,经过一番周折,终于找到了解决的办法,现在分享给大家。
.NET 4.0 调用 C dll 触发 AccessViolationException 异常的处理方案
一、问题 最近做项目的时候,在<em>调用</em> c 写的 <em>dll</em> 的时候,遇到一个程序异常,发现捕捉不到,异常为:System.AccessViolationException 二、解决方案 详细内容和原理可以看下面引用的内容,我这里使用的方法是在方法名上面添加属性: [HandleProcessCorruptedStateExceptions] public static void main(){ ...
System.AccessViolationException: 尝试读取写入保护内存。这通常指示其他内存已损坏
之前也遇到过这样的问题,一直未解决,最后重新安装系统,终于解决了。 没想到1个月以后,又出现了这种情况,让我奔溃,这次决定一定要找出原因; 调试后发现, connection.Open();以后报错,System.AccessViolationException: <em>尝试</em><em>读取</em>或<em>写入</em>受<em>保护</em>的<em>内存</em>。这<em>通常</em><em>指示</em>其他<em>内存</em><em>已损坏</em>,网上搜了很多都没有作用。 然后我发现 连接本地数据库是好的,连接远程数据库
fnthex32.dll尝试读取写入保护内存。这通常指示其他内存已损坏
16年时候项目中也要用的斑马打印机打印中文汉字的要求,想借鉴这个控件(Fnthex32.<em>dll</em>)来完成,无奈都<em>失败</em>啦,后来是用C# 写成类给vb6.0<em>调用</em>把文本写在txtbox中,再生产图片,然后系列化解决的这个问题。rn最近用<em>c#</em> 重写这个斑马打印程序,就又想起这个控件,于是就决定重新研究一下,网上的基本都是9个参数(报错:<em>尝试</em><em>读取</em>或<em>写入</em>受<em>保护</em>的<em>内存</em>。这<em>通常</em><em>指示</em>其他<em>内存</em><em>已损坏</em>。)。无奈怎么都不成
System.AccessViolationException: 尝试读取写入保护内存
依旧是开发Android平板客户端与C#pc端通讯时遇到的问题。rn问题描述:rn当平板连接电脑时,已经有其他便携设备插在电脑上,此时用户登录pc端,pc只能部分用户登录,其他用户会使得程序坏死,弹出的错误是:rnrnrn[Managed to Native Transition]rnmscorlib.<em>dll</em>!System.RuntimeTypeHandle.GetTypeByName(strin
尝试读取写入保护内存。这通常指示其他内存已损坏
写了一个保存按钮nnnSaveFileDialog sfd = new SaveFileDialog();nif (sfd.ShowDialog() == DialogResult.OK)n{ ... }nnn nn用的这段,理论应该是没问题的nn但执行时却出现了如下错误nn nn不抛异常的话是在这个nnn很久以前了,数据丢失了……nnn于是乎上网寻找答案,nn发现了很多问题,但出错的原因各不相同...
C# emgucv 关于“尝试读取写入保护内存。这通常指示其他内存已损坏。” 解决办法
出现原因:Mat转换为Bitmap显示图像的同时,向richTextBox打印数据,就会报错。单独使用正常。nnnMat outImg = new Mat();n//中间代码省略...npictureBox1.Image = outImg.Bitmap;//问题出在这nnfor (int i = 0; i &amp;lt; 32; i++)n{n for (int j = 0; j &amp;lt; 32...
c# openCV图片传递-尝试读取写入保护内存。这通常指示其他内存已损坏。解决方法
未处理AccessViolationExceptionnn这<em>通常</em><em>指示</em>其他<em>内存</em><em>已损坏</em>,这里<em>内存</em>损坏并非物理的<em>内存</em>条损坏。猜想是执行到此步骤后,<em>内存</em>空间被清理了,没有找到<em>内存</em>地址的感觉。nnpublic static bool RecognizeCpositiveAndNegative(PictureBox pbox_disImage1, Mat tempimg)nn当<em>调用</em>此函数后,信息传递给te...
AE开发中的“尝试读取写入保护内存。这通常指示其他内存已损坏。”错误解析
IPolyline pPolyline2 = feature2.Shape as IPolyline;rnITopologicalOperator topoOperator = pPolyline2 as ITopologicalOperator;rn...rnILine line = lineSegCol.get_Segment(i) as Line;rnrnIGeometry geo = to
尝试读取写入保护内存。这通常指示其他内存已损坏。"">"尝试读取写入保护内存。这通常指示其他内存已损坏。"
C#下利用ffmpeg频繁解码,导致 System.AccessViolationException ,且无法捕捉而使软件经常崩溃。rnffmpeg的原理无法了解,不过现有二法捕捉此异常:rn法一:添加HandleProcessCorruptedStateExceptionsAttributernrn[HandleProcessCorruptedStateExceptions]nvoid DoSo
C# Marshal.PtrToStructure 尝试写入保护内存
结构内的string类型未给定长nn [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)] public string str;
新中新二代身份证dll调用,报尝试读取写入保护内存,这通常指示其他内存已损坏 这个错 ...
n rn rn rn rn新中新二代身份证<em>dll</em><em>调用</em>问题:rn <em>调用</em>这个<em>dll</em>时, 到这个方法: Syn_ReadMsg(nPort, 0, ref CardMsg),就报<em>尝试</em><em>读取</em>或<em>写入</em>受<em>保护</em>的<em>内存</em>。这<em>通常</em><em>指示</em>其他<em>内存</em><em>已损坏</em> 这个错,CardMsg是IDCardData这个结构体,结构体定义如下:rn [StructLayout(LayoutKind.Sequential, CharSet = ...
VS生成解决方案成功,运行页面时提示:[3000]尝试读取写入保护内存。这通常指示其他内存已损坏
在修改了VS2013里面的解决方案中的BIN文件后,系统生成解决方案各种报错。rnrnrn在多次修改后,没有报错。但是运行页面或者调试时,出现以下错误:rnrnrn[3000]<em>尝试</em><em>读取</em>或<em>写入</em>受<em>保护</em>的<em>内存</em>。这<em>通常</em><em>指示</em>其他<em>内存</em><em>已损坏</em>。 rnrnrnrn在网上搜索了半天,终于找到可行的、有效的解决办法(只对于本人的情况)rnrnrn用管理员身份运行CMD,输入netsh winsock reset,En
未经处理的异常在xx.exe中发生,尝试读取写入保护内存。这通常指示其他内存已损坏
1.检查传参是否有问题,是否缺少 ref 或者 out ,或是传入参数的类型是否正确,string 和 stringbuilder 等相似类型。rnrn
“System.AccessViolationException”类型的未经处理的异常在 未知模块。
Windown任务栏搜索框输入netsh winsock reset并执行、如果依然无效,则以管理员权限执行。
.NET3.5SP1 尝试读取写入保护内存的问题补丁
.NET3.5SP1 <em>尝试</em><em>读取</em>或<em>写入</em>受<em>保护</em>的<em>内存</em>的问题补丁。 微软官方补丁,仅供参考
SQL server 2008提示“应用程序的组件发生了无法处理的异常”, “ 尝试读取写入保护内存。这通常指示其他内存已损坏”的解决方法
在新建查询时出现提示“应用程序的组件发生了无法处理的异常”,关闭或者点击“继续”后弹出 “ <em>尝试</em><em>读取</em>或<em>写入</em>受<em>保护</em>的<em>内存</em>。这<em>通常</em><em>指示</em>其他<em>内存</em><em>已损坏</em>”:上网找了很久,说是通过   管理员身份运行 cmd -&amp;gt;  输入 netsh winsock reset 解决的比较多但是我试过几遍都不行。无奈之下只好找到SQL server 2008的安装中心选择“修复”之后会要求选择安装媒体,选择你的S...
斑马条码打印机打印汉字的DLL(Fnthex32.dll)
直接将文档解压缩后复制到system32文件夹中即可 为实现斑马打印机对汉字的打印,需<em>调用</em>Fnthex32.<em>dll</em>的函数GETFONTHEX()对汉字进行转换, C申明: function int GETFONTHEX(string outstr,string fontname, int orient,int height,int width,int bold,int ITalic,ref string hexbuf) library "fnthex32.<em>dll</em>" 函数<em>调用</em>: integer int_filenum string named,cBuf GETFONTHEX("条码测试", "宋体", "chnstr01", 0, 50, 0, 1, 0, cBuf) //测试汉字转换是否成功// named='test.txt' int_filenum=FileOpen(named,StreamMode!,write!,Lockwrite!,Append!) filewrITe(int_filenum,cBuf) fileclose(int_filenum) VB中申明: Private Declare Function GETFONTHEX Lib "fnthex32.<em>dll</em>" (ByVal chnstr$, ByVal fontname$, ByVal chnname$, ByVal orient%, ByVal height%, ByVal width%,ByVal bold%, ByVal italic%, ByVal hexbuf$) As Integer <em>调用</em>: nCount = GETFONTHEX("条码测试", "宋体", "chnstr02", 0, 50, 0, 1, 0, cBuf)
基于emgu.CV(C#)实现人脸识别的探索,基于本机、IP(未完)两方面
     近期做一个有关人脸识别的任务,首先肯定是基于前人探索的前提下,找到一个很好的案例nnhttps://blog.csdn.net/u011616825/article/details/51620061  nn源代码要50积分,下载下来了可以用,放到这里https://download.csdn.net/download/lsc_hei/10861111 自行下载nn一、  基于本地计算机人...
C# PInvoke 函数“************”的调用导致堆栈不对称
问题描述:nn 在使用托管代码<em>调用</em>非托管代码发生“对PInvoke数“UseTwiHikVisionDllTest!UseTwiHikVisionDllTest.TwiHikVision::GetFirstPic”的<em>调用</em>导致堆栈不对称。原因可能是托管的PInvoke 签名与非托管的目标签名不匹配。请检查 PInvoke 签名的<em>调用</em>约定和参数与非托管的目标签名是否匹配。...
C#调用C++编写的opencv DLL的时候遇见的问题
最近做一个图像处理的简单程序,使用C#做界面,<em>调用</em>Opencv编写的DLL进行视频处理,只是简单的找一些边界轮廓什么的,但中间遇到了很多问题,也是因为自己太菜,所以走了很多弯路,但目前为止都解决了,这里先记录一波,方便以后查看。nn第一个问题是<em>调用</em><em>dll</em>时候传参的问题,不同于一些普通参数,比如字符串或者数组什么的,图像的格式比较复杂,没有对应的数据结构可以当做参数传输,像C#中数组,可以在编写的C...
tessnet2和3版本混用后程序错误的解决
这几天在使用tessnet2开发OCR程序,开始是使用2.0.4.0版本,程序正常。rnrnrn后来测试使用3.0.2.0的Tesseract,结果回来发现2.0.4.0的用不了,提示Unable to load unicharset file C:\Program Files (x86)\Tesseract-OCR\eng.unicharsetrnrnrn看上去是加载语言包的路径不正确。rnrn
C#门禁面部识别系统 超级牛
C#门禁面部识别系统 超级牛
c#调用c++动态库实现图像的读入与保存
第一次写,如有问题请多包涵~nn1nnnn2nnnn3 添加opencv项目属性表nnnn4 写代码 实现读入图像并保存nnnn5 添加头文件nnnn6 头文件中添加如下内容nnnn7 添加def文件nnnn8 在def文件添加如下内容nnnn9 生成解决方案 ,如果报错 “严重性 代码 说明 项目 文件 行 列 禁止显示状态n错误 C4996 'fopen': This function or ...
C#调用dll尝试读取写入保护内存。这通常指示其他内存已损坏。”
编译OK,调试时候显示的错误rn<em>尝试</em><em>读取</em>或<em>写入</em>受<em>保护</em>的<em>内存</em>。这<em>通常</em><em>指示</em>其他<em>内存</em><em>已损坏</em>。rnrn************** 异常文本 **************rnSystem.AccessViolationException: <em>尝试</em><em>读取</em>或<em>写入</em>受<em>保护</em>的<em>内存</em>。这<em>通常</em><em>指示</em>其他<em>内存</em><em>已损坏</em>。rn 在 HZbox.HZjudge.DoRecognize(Byte[] byteSerializedCh, Int32 iByteNum, Int16 chDestCh, Int16& chWrittenCh, Double[] pEvalout, Int32 iENum, Int32[] state, Byte[] ch)rn 在 HZbox.HZjudge.Judge() 位置 I:\GoogleCode\hzapp\HZcomponent.HZbox\HZjudge.cs:行号 114rnrnrn<em>dll</em>是C++的,是写.def的方式导出的方法rn原来的声明是这样的rn[code=C/C++]rnBOOL DoRecognize(rn const unsigned char* pWriteData, rn const int iDataLen, rn const unsigned short iDestWChar,rn unsigned short* iWrittenChar, rn double* pEvalOut, rn const int iENumber,rn int *state,rn char *cs);rn[/code]rn用在C#里我写成了rn[code=C#]rn[DllImport(@"C:\Windows\System32\RIT.<em>dll</em>", EntryPoint="DoRecognize")]rnstatic extern int DoRecognize(rn byte[] byteSerializedCh,rn int iByteNum,rn short chDestCh,rn ref short chWrittenCh,rn double[] pEvalout,rn int iENum,rn int[] state,rn byte[] ch);rn[/code]rn总觉得是不是类型错了。rnrn另外还有一点不知道值不值得一说,rn这个<em>dll</em>回<em>读取</em>txt文件的,一开始<em>调用</em>是文件读不到,所以我把<em>dll</em><em>读取</em>的文件路径都改成了绝对路径,放在system32下。rn然后就变成了这样的错误,请高手指教~
c#调用DLL尝试读取写入保护内存。这通常指示其他内存已损坏
DELPHI里<em>dll</em>的源码rnrnrnfunction Init(const CDT:integer):integer;stdcall;rn //释放对象 =0成功;=1<em>失败</em>rn function UnInit:integer;stdcall;rn //主机初始化com口函数 =0成功;=1<em>失败</em>rn function InitCom(const comid:string):integer;stdcall;rn //设置读写器状态 =0成功;=1<em>失败</em>rn function SetState(const state:integer):integer;stdcall;rn //<em>读取</em>卡号 =1<em>失败</em>rn function ReadCard(buffer: PChar; bufferlen: integer):integer;stdcall;rn //写信息到卡片中 =0成功;=1<em>失败</em> mark=0 默认密码FF FF FF FF FF FF =1 新密码 d2 bb c3 f9 cc ecrn function WriteInfo(const mark:integer;const id:integer; const d1:integer;const d2:integer;const d3:integer;const d4:integer;rn const d5:integer;const d6:integer;const d7:integer;const d8:integer;const d9:integer;rn const d10:integer;const d11:integer;const d12:integer;const d13:integer;const d14:integer;rn const d15:integer;const d16:integer):integer;stdcall;rn //读信息到卡片中 =0成功;=1<em>失败</em> mark=0 默认密码FF FF FF FF FF FF =1 新密码 d2 bb c3 f9 cc ecrn function ReadInfo(const mark:integer;const id:integer;d1:PChar;d2:PChar;d3:PChar;d4:PChar;d5:PChar;d6:PChar;d7:PChar;rn d8:PChar;d9:PChar;d10:PChar;d11:PChar;d12:PChar;d13:PChar;d14:PChar;d15:PChar;d16:PChar):integer;stdcall;rn //*******************内部函数**************************rn //设置发送数据标识rn function SetMark(const handle:THandle;const mark:byte):integer;rn //发送数据函数 =0成功;=1<em>失败</em> =3 mark位设置<em>失败</em>rn function SendData(const handle:THandle):integer;rn //接收数据函数 =0成功;=1<em>失败</em> =11 接收<em>失败</em> =12 接收头错误 =5 超时错误rn function InceptData(const handle:THandle):integer;rn //计算效验值 //mark=1 读,=0 写rn function ComputeEfficacy(mark:integer):integer;rn我<em>调用</em>C#<em>调用</em>rnrn [DllImport("Project2.<em>dll</em>")]rn private static extern int Init(int CDT);rn //释放对象 =0成功;=1<em>失败</em>rn [DllImport("Project2.<em>dll</em>")]rn private static extern int UnInit();rnrn //主机初始化com口函数 =0成功;=1<em>失败</em>rn [DllImport("Project2.<em>dll</em>")]rn private static extern int InitCom(string comid);rn //设置读写器状态 =0成功;=1<em>失败</em>rn [DllImport("Project2.<em>dll</em>")]rn private static extern int SetState(int state);rn //<em>读取</em>卡号 =1<em>失败</em>rn [DllImport("Project2.<em>dll</em>")]rn private static extern int ReadCard(ref string buffer, byte bufferlen);rn //写信息到卡片中 =0成功;=1<em>失败</em> mark=0 默认密码FF FF FF FF FF FF =1 新密码 d2 bb c3 f9 cc ecrn [DllImport("Project2.<em>dll</em>")]rn private static extern int WriteInfo(int mark,int id,int d1, int d2, int d3,int d4,int d5,int d6,int d7, int d8,int d9,int d10,int d11,int d12,int d13,int d14,int d15,int d16);rnrn //读信息到卡片中 =0成功;=1<em>失败</em> mark=0 默认密码FF FF FF FF FF FF =1 新密码 d2 bb c3 f9 cc ecrn [DllImport("Project2.<em>dll</em>")]rn private static extern int ReadInfo(int mark,int id,ref string d1,ref string d2,ref string d3,ref string d4,ref string d5,ref string d6,ref string d7,ref string d8,ref string d9,ref string d10,ref string d11,ref string d12,ref string d13,ref string d14,ref string d15,ref string d16);rn //*******************内部函数**************************rn //设置发送数据标识rn [DllImport("Project2.<em>dll</em>")]rn private static extern int SetMark(ref IntPtr handle, byte mark);rn //发送数据函数 =0成功;=1<em>失败</em> =3 mark位设置<em>失败</em>rn [DllImport("Project2.<em>dll</em>")]rn private static extern int SendData(IntPtr handle);rn //接收数据函数 =0成功;=1<em>失败</em> =11 接收<em>失败</em> =12 接收头错误 =5 超时错误rn [DllImport("Project2.<em>dll</em>")]rn private static extern int InceptData( IntPtr handle);rn //计算效验值 //mark=1 读,=0 写rn [DllImport("Project2.<em>dll</em>")]rn private static extern int ComputeEfficacy(int mark);rn
C#调用dll尝试读取写入保护内存。这通常指示其他内存已损坏"
该DLL是将DICOM图片格式传到PIVIEW中。该程序在VC里已经实现,现要在C#里实现。<em>dll</em>里方法接口为BOOL __stdcall dicom_storescu_execute(LPCSTR servername, int serverport,rnLPCSTR servertitle, LPCSTR clienttitle, rnLPCSTR filelist, STORESCUCALLBACK callback);rn其中STORESCUCALLBACK 是一个函数指针typedef void (__stdcall * STORESCUCALLBACK)(T_StoreProgress* progress);。rn<em>调用</em>为:rn isSuccessed = dicom_storescu_execute(TheadIPadress,rn TheadServerPort ,rn TheadServerTitle,rn TheadClientTitle, rn TheadImageFile ,rn MyStoreScuCallback);rnMyStoreScuCallback为一函数名rn在C#中rnpublic delegate void STORESCUCALLBACK(T_StoreProgress progress);rn[DllImport("dcmtrans.<em>dll</em>", EntryPoint = "dicom_storescu_execute")]rn public static extern bool dicom_storescu_execute(string servername,rn int serverport, string servertitle, string clienttitle,rn string filelist, STORESCUCALLBACK callback);rn<em>调用</em>为rnrn internal unsafe void startSCU(Object lpParam)rn rn StoreSCUThead scu_CS = (StoreSCUThead)lpParam;rn string TheadIPadress = scu_CS.strIPadress;rn int TheadServerPort = scu_CS.strServerPort;rn string TheadServerTitle = scu_CS.strServerTitle;rn string TheadClientTitle = scu_CS.strClientTitle;rn string TheadImageFile = scu_CS.strImageFile;rn int mxh = scu_CS.Theadxh;rn bool isSuccessed = false;rn STORESCUCALLBACK callback = new STORESCUCALLBACK(MyStoreScuCallback);rn isSuccessed = dicom_storescu_execute(TheadIPadress,rn TheadServerPort,rn TheadServerTitle,rn TheadClientTitle,rn TheadImageFile,rn callback);rnrn if (!isSuccessed)rn falseNum++;rn rnrnMyStoreScuCallback为函数名rn public void MyStoreScuCallback(T_StoreProgress progress)rn rn switch (progress.state)rn rn case T_StoreProgressState.StoreBegin:rn break;rn case T_StoreProgressState.StoreProgressing:rn break;rn case T_StoreProgressState.StoreEnd:rn break;rn default:rn break;rn rn rn其中startSCU是开辟一个线程<em>调用</em>的rn internal unsafe void OnSend(string path)rn rn string m_aetitle="";rn string m_ip = "";rn int m_port = 0;rn string m_Filename = "";rn string m_path = "";rn StringBuilder m_tmp = new StringBuilder(255);rn m_Filename = path + "test.dcm";rn m_path = path + "user_setting.ini";rn GetPrivateProfileString("SetupDCM", "aetitle", null, m_tmp, 15, m_path);rn m_aetitle = m_tmp.ToString();rn GetPrivateProfileString("SetupDCM" , "ip" , null , m_tmp , 15 , m_path);rn m_ip = m_tmp.ToString();rn GetPrivateProfileString("SetupDCM", "port", null, m_tmp, 15, m_path);rn m_port = Int32.Parse(m_tmp.ToString());rn StoreSCUThead uStoreSCUThead = new StoreSCUThead();rn uStoreSCUThead.strIPadress = m_ip;rn uStoreSCUThead.strServerPort = m_port;rn uStoreSCUThead.strServerTitle = "OPACS";rn uStoreSCUThead.strClientTitle = m_aetitle;rn uStoreSCUThead.strImageFile = m_Filename;rn uStoreSCUThead.Theadxh = 1;rn //Thread fThread = new Thread(new ThreadStart(startSCU));rn Thread fThread = new Thread(startSCU);rn fThread.Start(uStoreSCUThead);rn fThread.Join(<em>100</em>0);rn rn一编译就出错在<em>调用</em>函数dicom_storescu_execute“这报<em>尝试</em><em>读取</em>或<em>写入</em>受<em>保护</em>的<em>内存</em>”的错。请问各位大哥,我是不是函数指针转化的类型出错啦?而且我把MyStoreScuCallback里参数换为不是指针类型的了。这些有影响吗?rnrnrn
C#调用DLL 尝试读取写入保护内存。这通常指示其他内存已损坏
// 参数: pstConvInfo 指向用来保存设备列表的缓存rn// iCount 为缓存中可保存多少个ST_CONVINFO结构。rn// iTimeOut 超时时间, 单位为毫秒rn// 返回: 搜索到的设备个数rnDLL_CONVERTER int CONV_FindConverter(ST_CONVINFO* pstConvInfo, int iCount, int iTimeOut);rn// 设备信息rn[code=c]typedef structrnrn char strMAC[20];rn char strIP[20];rnchar strUserName[64];rnchar strDeviceName[64];rnST_CONVINFO;[/code]rn以上是VC入口函数和结构体rnrn以下是C# 代码,请问大神们问题以下rnrn [code=csharp] [DllImport("Converter.<em>dll</em>")]rn static extern int CONV_FindConverter(ref ST_CONVINFO pstConvInfo, int iCount, int iTimeOut);rn [DllImport("Converter.<em>dll</em>")]rn static extern bool CONV_Init();rn rn public struct ST_CONVINFOrn rn [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]rn public string strMAC;rn [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]rn public string strIP;rn [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)]rn public string strUserName;rn [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)]rn public string strDeviceName;rn rn rn private void button1_Click(object sender, EventArgs e)rn rn ST_CONVINFO st_=new ST_CONVINFO ();rn CONV_Init();rn CONV_FindConverter( ref st_ ,1,<em>100</em>);rn rn string stm = st_.strMAC;rn string stip=st_.strIP;rn [/code]rnrn当 st_ 返回为两个或两个以的结构数据就会出现以下错误 如果只返回一个结构数据就没有问题,大神们请指点下rn[img=https://img-bbs.csdn.net/upload/201405/29/1401353272_445964.jpg][/img]
System.AccessViolationException: 尝试读取写入保护内存。这通常指示其他内存已损坏。解决办法
有关<em>调用</em>实时(JIT)调试而不是此对话框的详细信息,rn 2请参见此消息的结尾。rn 3rn 4************** 异常文本 **************rn 5System.AccessViolationException: <em>尝试</em><em>读取</em>或<em>写入</em>受<em>保护</em>的<em>内存</em>。这<em>通常</em><em>指示</em>其他<em>内存</em><em>已损坏</em>。rn 6 在 System.Drawing.SafeNativeMethods.Gdip.GdipDrawRectangleI(HandleRef graphics, HandleRef pen, Int32 x, Int32 y, Int32 width, Int32 height)rn 7 在 System.Drawing.Graphics.DrawRectangle(Pen pen, Int32 x, Int32 y, Int32 width, Int32 height)rn 8 在 System.Drawing.Graphics.DrawRectangle(Pen pen, Rectangle rect)rn 9 在 System.Windows.Forms.ComboBox.FlatComboAdapter.DrawFlatCombo(ComboBox comboBox, Graphics g)rn10 在 System.Windows.Forms.ComboBox.WndProc(Message& m)rn11 在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)rn12 在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)rn13 在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)rn14rn15rn16************** 已加载的程序集 **************rn17mscorlibrn18 程序集版本: 2.0.0.0rn19 Win32 版本: 2.0.50727.832 (QFE.050727-8300)rn20 基本代码: file:/**////C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.<em>dll</em>rn21----------------------------------------rn22System.Windows.Formsrn23 程序集版本: 2.0.0.0rn24 Win32 版本: 2.0.50727.832 (QFE.050727-8300)rn25 基本代码: file:/**////C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.<em>dll</em>rn26----------------------------------------rn27Systemrn28 程序集版本: 2.0.0.0rn29 Win32 版本: 2.0.50727.832 (QFE.050727-8300)rn30 基本代码: file:/**////C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.<em>dll</em>rn31----------------------------------------rn32System.Drawingrn33 程序集版本: 2.0.0.0rn34 Win32 版本: 2.0.50727.832 (QFE.050727-8300)rn35 基本代码: file:/**////C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.<em>dll</em>rn36----------------------------------------rn37System.Configurationrn38 程序集版本: 2.0.0.0rn39 Win32 版本: 2.0.50727.832 (QFE.050727-8300)rn40 基本代码: file:/**////C:/WINDOWS/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.<em>dll</em>rn41----------------------------------------rn42System.Xmlrn43 程序集版本: 2.0.0.0rn44 Win32 版本: 2.0.50727.832 (QFE.050727-8300)rn45 基本代码: file:/**////C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.<em>dll</em>rn46----------------------------------------rn47mscorlib.resourcesrn48 程序集版本: 2.0.0.0rn49 Win32 版本: 2.0.50727.832 (QFE.050727-8300)rn50 基本代码: file:/**////C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.<em>dll</em>rn51----------------------------------------rn52System.Windows.Forms.resourcesrn53 程序集版本: 2.0.0.0rn54 Win32 版本: 2.0.50727.42 (RTM.050727-4200)rn55 基本代码: file:/**////C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms.resources/2.0.0.0_zh-CHS_b77a5c561934e089/System.Windows.Forms.resources.<em>dll</em>rn56----------------------------------------rn57rn58************** JIT 调试 **************rn59要启用实时(JIT)调试,rn60该应用程序或计算机的 .config 文件(machine.config)的 system.windows.forms 节中必须设置rn61jitDebugging 值。rn62编译应用程序时还必须启用rn63调试。rn64rn65例如: rn66rn67rn68 rn69rn70rn71启用 JIT 调试后,任何无法处理的异常rn72都将被发送到在此计算机上注册的 JIT 调试器,rn73而不是由此对话框处理。
未处理 System.AccessViolationException Message:尝试读取写入保护内存。这通常指示其他内存已损坏
今天把公司一个winform的程序移植到web上面,因为有些数据,通过软件麻烦,直接web展示方便,没想到出现这种情况,各位帮小弟看看到底是哪里出错了:rn先贴上winform的代码:rn这个是类文件:RDCAPI.csrn代码:rn[code=C#]using System;rnusing System.Collections;rnusing System.Configuration;rnusing System.Data;rnusing System.Linq;rnusing System.Web;rnusing System.Web.Security;rnusing System.Web.UI;rnusing System.Web.UI.HtmlControls;rnusing System.Web.UI.WebControls;rnusing System.Web.UI.WebControls.WebParts;rnusing System.Xml.Linq;rnusing System.Globalization;rnusing YD_EMS;rnusing System.Net.Sockets;rnusing System.Net;rnusing System.Text;rnrn// 实时数据回传 回调函数rnpublic delegate int RDC_VarOk(rn IntPtr handle,rn string lpszDbVarName,rn string lpszVal,rn string lpszdateTime,rn int dwUserData // rn );rnrnnamespace YD_EMSrnrn public partial class testApi : System.Web.UI.Pagern rn IntPtr m_handle;//句柄rnrn string strIP = "127.0.0.1"; //访问IPrnrn int nPort = 8109; //端口rnrnrn rn protected void Page_Load(object sender, EventArgs e)rn rn rnrn rn rn private int GetData(IntPtr handle,rn string lpszDbVarName,rn string lpszVal,rn string lpszdateTime,rn int dwUserData)rn rn rn if (lpszDbVarName == "d.test1")rn test1.Text = lpszVal;rnrn if (lpszDbVarName == "d.test2")rn test2.Text = lpszVal;rnrn if (lpszDbVarName == "d.test3")rn test3.Text = lpszVal;rnrnrn return 0;rn rn rn protected void Timer1_Tick(object sender, EventArgs e)rn rn //此段拿来测试页面刷新的,可以忽略。rn string str = DateTime.Now.ToString("tt") == "上午" ? "AM" : "PM";rn lblTime.Text = "当前时间为:" + DateTime.Now.ToString("yyyy年MM月dd日") + " " +rn CultureInfo.GetCultureInfo("zh-cn").DateTimeFormat.GetDayName(DateTime.Now.DayOfWeek) + " " +rn DateTime.Now.ToLongTimeString() + " " + str;rn rn rnrn protected void Button1_Click(object sender, EventArgs e)rn rn RDC_VarOk myCallBack = new RDC_VarOk(GetData);rn m_handle = App_Code.RDCAPI.RDC_Open(strIP, nPort, myCallBack, 0);// 打开数据连接rn App_Code.RDCAPI.RDC_AddVar(m_handle, "d,test1", 2);//增加标签rn App_Code.RDCAPI.RDC_AddVar(m_handle, "d,test2", 2);//增加标签rn App_Code.RDCAPI.RDC_AddVar(m_handle, "d,test3", 2);//增加标签rn int n = App_Code.RDCAPI.RDC_StartRun(m_handle);rn rnrn //**********************rn // 连接rn //**********************rn private static Socket ConnectSocket(string server, int port)rn rn Socket socket = null;rnrn IPHostEntry iphostentry = null;rnrn foreach (IPAddress address in iphostentry.AddressList)rn rnrn IPEndPoint IPEPoint = new IPEndPoint(address, port);rnrn Socket newSocket = new Socket(IPEPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);rnrn newSocket.Connect(IPEPoint);rnrn if (newSocket.Connected)rn rn socket = newSocket;rn break;rn rn elsern rn continue;rn rnrn rn return socket;rn rnrn //**********************rn // 发送与接收rn //**********************rnrn private static string SocketSendReceive(string server, int port)rn rn string request = "get var name";rnrn Byte[] btSend = Encoding.ASCII.GetBytes(request);rnrn Byte[] btReceived = new Byte[256];rnrn Socket socket = ConnectSocket(server, port);rnrn if (socket == null)rn return ("连接<em>失败</em>");rnrn socket.Send(btSend, btSend.Length, 0);rnrn int intContent = 0;rnrn string strContent = "";rnrn dorn rn intContent = socket.Receive(btReceived, btReceived.Length, 0);rnrn strContent += Encoding.ASCII.GetString(btReceived, 0, intContent);rnrn rn while (intContent > 0);rnrn return strContent;rnrn rnrn rnrn[/code]rnwinform窗口文件:Form1.csrn代码:rn[code=C#]using System;rnusing System.Collections.Generic;rnusing System.ComponentModel;rnusing System.Data;rnusing System.Drawing;rnusing System.Linq;rnusing System.Text;rnusing System.Windows.Forms;rnusing System.Net.Sockets;rnusing System.Net;rnusing System.Runtime.InteropServices;rnusing System.IO;rnrn// 实时数据回传 回调函数rnpublic delegate int RDC_VarOk(rn IntPtr handle,rn string lpszDbVarName,rn string lpszVal,rn string lpszdateTime,rn int dwUserData // rn );rnrnnamespace WindowsFormsApplication6rnrnrn public partial class Form1 : Formrn rnrnrnrn IntPtr m_handle;rnrn string strIP = "127.0.0.1";rnrn int nPort = 8109;rnrn public Form1()rn rn InitializeComponent();rnrn rn private void Form1_FormClosed(object sender, FormClosedEventArgs e)rn rn WindowsFormsApplication6.<em>dll</em>.RDCAPI.RDC_StopRun(m_handle);rn WindowsFormsApplication6.<em>dll</em>.RDCAPI.RDC_Close(m_handle);rn rnrn private void button6_Click(object sender, EventArgs e)//点击开始自动更新数据rn rnrnrn RDC_VarOk myCallBack = new RDC_VarOk(GetData);rnrn m_handle = WindowsFormsApplication6.<em>dll</em>.RDCAPI.RDC_Open(strIP, nPort, myCallBack, 0);rnrnrn WindowsFormsApplication6.<em>dll</em>.RDCAPI.RDC_AddVar(m_handle, "d.test1", 2);rn WindowsFormsApplication6.<em>dll</em>.RDCAPI.RDC_AddVar(m_handle, "d.test2", 2);rn WindowsFormsApplication6.<em>dll</em>.RDCAPI.RDC_AddVar(m_handle, "d.test3", 2);rnrn int n = WindowsFormsApplication6.<em>dll</em>.RDCAPI.RDC_StartRun(m_handle);rnrn rn private int GetData(IntPtr handle,rn string lpszDbVarName,rn string lpszVal,rn string lpszdateTime,rn int dwUserData)rn rn if (lpszDbVarName == "d.test1")rn textBox1.Text = lpszVal;rnrn if (lpszDbVarName == "d.test2")rn textBox2.Text = lpszVal;rnrn if (lpszDbVarName == "d.test3")rn textBox3.Text = lpszVal;rnrnrn return 0;rnrn rn rn rn rn rnrn//**********************rn// 连接rn//**********************rn private static Socket ConnectSocket(string server, int port)rn rn Socket socket = null;rnrn IPHostEntry iphostentry = null;rnrn foreach (IPAddress address in iphostentry.AddressList)rn rnrn IPEndPoint IPEPoint = new IPEndPoint(address,port);rnrn Socket newSocket = new Socket(IPEPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);rnrn newSocket.Connect(IPEPoint);rnrn if (newSocket.Connected)rn rn socket = newSocket;rn break;rn rn elsern rn continue;rn rnrnrn rnrn rn return socket;rn rnrn//**********************rn// 发送与接收rn//**********************rnrn private static string SocketSendReceive(string server,int port)rn rn string request="get var name";rnrn Byte[] btSend=Encoding.ASCII.GetBytes(request);rnrn Byte[] btReceived =new Byte[256];rnrn Socket socket=ConnectSocket(server,port);rnrn if(socket==null)rn return ("连接<em>失败</em>");rnrn socket.Send(btSend,btSend.Length,0);rnrn int intContent=0;rnrn string strContent="";rnrn dorn rn intContent =socket.Receive(btReceived,btReceived.Length,0);rnrn strContent+=Encoding.ASCII.GetString(btReceived,0,intContent);rnrn rn while(intContent>0);rnrn return strContent;rnrn rnrn rn rnrn[/code][color=#FF0000]以上的在winform的项目里面运行至正常的[/color]rnrn下面是我移植到web上面的时候的代码,其中类文件RDCAPI.cs不变,代码也一样;rnrn这个是web页面名称:testApi.aspxrn页面代码(采用页面无刷新效果,因为采集的数据是实时更新的,需要定时刷新):rn[color=#FF0000]由于字数限制,我把代码贴在一楼[/color]rnrnDeBug项目的时候,报错如下:rn[color=#FF0000]未处理 System.AccessViolationExceptionrnMessage: <em>尝试</em><em>读取</em>或<em>写入</em>受<em>保护</em>的<em>内存</em>。这<em>通常</em><em>指示</em>其他<em>内存</em><em>已损坏</em>。[/color]
System.AccessViolationException: 尝试读取写入保护内存。这通常指示其他内存已损坏
/// rn /// 要显示的测控任务对象。rn /// rn [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Browsable(false)]rn public ISK.ISKJobSta Jobrn rn getrn rn return m_job;rn rn setrn rn if (value == null) return; rnrn lock (m_RelTaskDetailLock)rn rn m_job = value;rnrn UpdateBasicInfo();rn UpdateStationList();rn rn rn rn private ISK.ISKJobSta m_job;rn private string m_currStation = string.Empty;rnrn private void UpdateStationList()rn rn foreach (ToolStripItem item in this.toolStrip1.Items)rn rn ToolStripButton button = item as ToolStripButton;rn if (button != null && button.Tag != null)rn rn button.Enabled = false;rn button.Text = m_stationIdNames[button.Tag.ToString()];rn rn rnrn // 遍历所有站标rn int stnCount = Math.Min(m_job.job.StationNum, 10);rnrn bool currStationHasData = false;rn Station[] stations = m_job.job.station;rn for (int i = 0; i < stnCount; ++i)rn rn Station stn = stations[i];rnrn // 每个Station对应于哪个地面站按钮rn foreach (ToolStripItem item in this.toolStrip1.Items)rn rn ToolStripButton button = item as ToolStripButton;rn if (button != null && button.Tag != null)rn rn if (button.Tag.ToString() == stn.StationName)rn rn button.Enabled = true;rn button.Text = string.Format("0 (1)"rn , m_stationIdNames[stn.StationName], stn.StepNum.ToString());rn rn rn // end of foreachrnrn if (stn.StationName == m_currStation)rn rn currStationHasData = true;rn rn rnrn if (currStationHasData)rn rn UpdateStationInfo(m_currStation);rn rn elsern rn m_currStation = string.Empty;rn MakeSingleButtonChecked(this.toolStrip1.Items[0] as ToolStripButton);rn SwitchToBasicInfoPanel();rn rn rnrn void OnStationButtonClick(object sender, EventArgs e)rn rn lock (m_RelTaskDetailLock)rn rn SwitchToStationInfoPanel();rnrn if (m_job == null) return; rnrn ToolStripButton button = sender as ToolStripButton;rnrn string id = button.Tag.ToString();rn m_currStation = id;rnrn UpdateStationInfo(id);rn rn rnrn private void UpdateStationInfo(string stationId)rn rn Station stn = null;rnrn [color=#FF0000] Station[] stations = m_job.job.station;rn int count = Math.Min(stations.Length, m_job.job.StationNum);[/color]rn for (int i = 0; i < count; ++i)rn rn if (stations[i].StationName == stationId)rn rn stn = stations[i];rn break;rn rn rnrn if (stn == null) return; rnrn // 地面站描述信息rn int row = 0;rnrn SetItemValue(this.lvStationInfo.Items[row++], stn.SerNo.ToString());rn //SetItemValue(this.lvStationInfo.Items[row++], stn.StationName);rn SetItemValue(this.lvStationInfo.Items[row++], stationFormat(stn.StationName));rn SetItemValue(this.lvStationInfo.Items[row++], stn.GrndStaLevel.ToString());rn //SetItemValue(this.lvStationInfo.Items[row++], stn.RecvFlag.ToString());rn SetItemValue(this.lvStationInfo.Items[row++], isRecvFormat(stn.RecvFlag));rn //SetItemValue(this.lvStationInfo.Items[row++], stn.StationSta.ToString());rn SetItemValue(this.lvStationInfo.Items[row++], OCSOrbRelTaskList.GetJobStatusText(stn.StationSta));rn SetItemValue(this.lvStationInfo.Items[row++], stn.Explain);rnrn // 质量信息rn row = 0;rnrn ISK.Quality quality = stn.quality;rn SetItemValue(this.lvQuality.Items[row++], quality.LostPacket.ToString());rn SetItemValue(this.lvQuality.Items[row++], OrbMissRateFormat(quality.OrbMissRate));rn SetItemValue(this.lvQuality.Items[row++], quality.OrbRecvRate.ToString());rnrn // 事件描述(作业步)rn ISK.Step[] steps = stn.step;rn int stepNum = Math.Min(steps.Length, stn.StepNum);rnrn this.labEvent.Text = string.Format("事件描述(共0个):", stepNum);rnrn this.lvEvents.BeginUpdate();rn this.lvEvents.Items.Clear();rn for (int i = 0; i < stepNum; ++i)rn rn ISK.Step step = steps[i];rnrn ListViewItem item = new ListViewItem();rn item.Text = step.StepNo.ToString();rn item.SubItems.Add(step.StepName);rn item.SubItems.Add(repStatusFormat(step.RepStatus));rn item.SubItems.Add(OCSOrbRelTaskList.GetJobStatusText(step.StepStatus));rn item.SubItems.Add(step.StepInfo);rn if (step.SchTime == 0)rn rn item.SubItems.Add("");rn rn elsern rn item.SubItems.Add(OCSOrbRelTaskList.GetDateTimeFromSec(step.SchTime).ToString("yyyy-MM-dd rnrnHH:mm:ss"));rn rn if (step.RealTime == 0)rn rn item.SubItems.Add("");rn rn elsern rn item.SubItems.Add(OCSOrbRelTaskList.GetDateTimeFromSec(step.RealTime).ToString("yyyy-MM-dd rnrnHH:mm:ss"));rn rn if (step.UpdTime == 0)rn rn item.SubItems.Add("");rn rn elsern rn item.SubItems.Add(OCSOrbRelTaskList.GetDateTimeFromSec(step.UpdTime).ToString("yyyy-MM-dd rnrnHH:mm:ss"));rn rn item.SubItems.Add(step.Explain);rnrn this.lvEvents.Items.Add(item);rn rn this.lvEvents.EndUpdate();rn rnrnrn说明:上面的这段代码是出现此处问题的关键地方,Job 对象不断的更新,同时当我点击按钮触发的是OnStationButtonClick事件时在红色字体区域就出现如下异常,请问这个问题该怎么解决?
调用dll出错 尝试读取写入保护内存。这通常指示其他内存已损坏
[DllImport"LBSMonitor.<em>dll</em>", CharSet = CharSet.Ansi)]rnpublic static extern int MonitorShowPlayBackDlg(string str);rnrnrn<em>调用</em>代码 private void PbPlayBack_Click(object sender, EventArgs e)rn rn string str = "C:\\JYvideo\\";rn int a = VideoManage.MonitorShowPlayBackDlg(str);rn rn困扰我好几天了网上找了好多都不符合我的情况,刚接触这一块什么都不懂,请高手们指点一下
调用DLL时,尝试读取写入保护内存。这通常指示其他内存已损坏
做读卡程序,读卡器厂家给了我一个DLL文件。"JINCARD.<em>dll</em>"现在<em>调用</em>sele_exp_port(int,string)函数的时候提示:rn"<em>尝试</em><em>读取</em>或<em>写入</em>受<em>保护</em>的<em>内存</em>。这<em>通常</em><em>指示</em>其他<em>内存</em><em>已损坏</em>"。请问大家是什么原因? <em>内存</em>地址是:"0000913C"rn请大家帮分析下原因rnrn[code=C#]rnpublic partial class Form1 : Formrn rn public class DLL_Openrn rn [DllImport("JINCARD7.<em>dll</em>", EntryPoint = "Init_com")]rn public static extern String Init_com(String flag_c,String bit_c,String check_c,String data_c,String stop_c );rn [DllImport("JINCARD7.<em>dll</em>", EntryPoint = "sele_exp_port")]rn public static extern String sele_exp_port(Int32 coms,String exp);rn rnrn public Form1()rn rn InitializeComponent();rn rnrn private void button1_Click(object sender, EventArgs e)rn rn rn DLL_Open.Init_com("1","9600","N","8","1");rn DLL_Open.sele_exp_port(1,"B");rn MessageBox.Show("初始化串口成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);rn rn rn rn[/code]
c#引用DLL,尝试读取写入保护内存。这通常指示其他内存已损坏
最近在对华视电子的二代身份证读卡器进行二次开发。<em>调用</em>里面的termb.<em>dll</em>,代码如下:rnrn//源程序说明文件中对函数的说明rn4.1 初始化连接rn原 型:int CVR_InitComm (int Port)rn说 明:本函数用于PC与华视电子第二代居民身份证阅读器的连接。rn参 数:Port:连接串口或USB口rn值 意义rn1 串口1rn2 串口2rn3 串口3rn4 串口4rn<em>100</em>1 USB口1rn<em>100</em>2 USB口2rn<em>100</em>3 USB口3rn<em>100</em>4 USB口4rnrn返 回 值: 意义rn1 正确rn0 错误rnrn//申明部分rn[DllImport("termb.<em>dll</em>")]rnprivate static extern int CVR_InitComm(int Port);rnrn//<em>调用</em>部分(判断读卡器是否连接到计算机)rn public static bool InitComm()rnrn rn if ((CVR_InitComm(<em>100</em>1)==1)||(CVR_InitComm(<em>100</em>2)==1)rn ||(CVR_InitComm(<em>100</em>3)==1)||(CVR_InitComm(<em>100</em>4)==1))rn rn return true;rn rn elsern rn return false;rn rn rngoogle了好久,也没找到合适的方法。希望这里能找到解决方案。
尝试读取写入保护内存.这通常指示其它内存已损坏
<em>尝试</em><em>读取</em>或<em>写入</em>受<em>保护</em>的<em>内存</em>.这<em>通常</em><em>指示</em><em>其它</em><em>内存</em><em>已损坏</em>rnrnweb matrix移按钮是出错
c#调用VC++6 的DLL,报错:System.AccessViolationException: 尝试读取写入保护内存。这通常指示其他内存已损坏
烦请各位大侠帮忙看看:rn一个C++写的DLL,在C#的Windows应用程序中可以被正常<em>调用</em>,但在Web应用程序<em>调用</em>时系统报错:rn System.AccessViolationException: <em>尝试</em><em>读取</em>或<em>写入</em>受<em>保护</em>的<em>内存</em>。这<em>通常</em><em>指示</em>其他<em>内存</em><em>已损坏</em>。rn跟踪了下 ,C++中的报错代码如下:rn TSplitInfo tFront[SR_DICTIONARY_MAXWORDLEN];rn TSplitInfo tBehind[SR_DICTIONARY_MAXWORDLEN];rn //memset(tFront,0,sizeof(struct TSplitInfo)*SR_DICTIONARY_MAXWORDLEN);rn //memset(tBehind,0,sizeof(struct TSplitInfo)*SR_DICTIONARY_MAXWORDLEN);rn rn [color=#FF0000]if(m_oSplitWord.SplitFrontAndBehind(szWord,dwNumHz,&tFront[0],&tBehind[0])) [/color]rn rn 我试着用memset去为这两个结构体分配空间,还是报同样的错误,rn结构体定义如下:rn/* 两字词 */rnstruct TTwoHzrn WORD wHzCode[3];rn char szReserved[2];rn ;rn char szName[8];rn ;rn DWORD dwPinYinID[4];rn DWORD dwFrCost;rn;rn/* 词表 */rnstruct TWordTablernrn DWORD dwSizeTable;rn DWORD dwNumTwo;rn unionrn rn DWORD dwOffsetTwo;rn TTwoHz* pTwoHz;rn ;rn DWORD dwNumThree;rn unionrn rn DWORD dwOffsetThree;rn TThreeHz* pThreeHz;rn ;rn DWORD dwNumFour;rn unionrn rn DWORD dwOffsetFour;rn TFourHz* pFourHz;rn ;rn DWORD dwPinYinID;rn DWORD dwFrCost;rn;rnstruct TSplitInfornrn int nNumHz; /* 汉字数目 */rn unionrn rn TWordTable* pWordTable;rn TTwoHz* pTwoHz;rn TThreeHz* pThreeHz;rn TFourHz* pFourHz; rn ;rn;rnrnrn unionrn rn structrn rn WORD wHzCode;rn char szReserved[2];rn ;rn char szName[4];rn ;rn DWORD dwPinYinID[2];rn DWORD dwFrCost;rn;rn/* 三字词 */rnstruct TThreeHzrn rn unionrn rn WORD wHzCode[2];rn char szName[4];rn ;rn DWORD dwPinYinID[3];rn DWORD dwFrCost;rn;rn/* 四字词 */rnstruct TFourHzrnrn unionrn rn structrn rn WORD wHzCode[3];rn char szReserved[2];rn ;rn char szName[8];rn ;rn DWORD dwPinYinID[4];rn DWORD dwFrCost;rn;rnrnrn rn
winform中调用moonpdflib
winform中<em>调用</em>moonpdflib(wpf控件)
调用接口报错:尝试读取写入保护内存,这通常指示其他内存已损坏
我要实现一个远程开门的一个功能,门禁人家的接口是rn6 ControlDevice rn[函数] int ControlDevice(HANDLE handle, LONG OperationID, LONG Param1, LONG Param2, LONG Param3, LONG Param4, const char *Options) rn[功能] 控制控制器动作。rn [参数说明]rn handle [in] 由 Connect()成功返回的句柄;rn OperationID [in] 操作内容:1 表示锁输出或者辅助输出,2 表示取消报警,3 重启设备,4 启用和 禁用常开(这里的禁用常开包括首开常开、连续五次卡启用的常开、远程启用的常开)。 rnParam1 [in] 当 OperationID 为输出操作时,若 Param2 为门输出,此参数表示设备中门 的编号,若 Param2 为辅助输出,此参数表示设备中辅助输出口的编号,详细请参 见附表三;rn当 OperationID 为取消报警时,默认值为 0;rn Param2 [in] 当OperationID为输出操作时,此参数表示设备输出点地址类型(1:锁输出, 2: 辅助输出),详细请参见附表三;当OperationID为取消报警时,默认值为0;当 OperationID 为4,即常开时,该参数表示是常开启用还是禁用常开(0:禁用;1:启用);rn Param3 [in] 当 OperationID 为输出操作时,此参数表示开门时间(0 表示关,255 表示 常开,取值范围为 1~60(秒)),默认值为 0;rn Param4 [in] 预留之用,默认为 0; Option [in] 默认为空,扩展之用; [返回值] 返回为 0 或者正数时,表示成功;返回负数时表示<em>失败</em>,错误代码的信息请参 见附表五。rn [示例] Python : # 开编号为 1 的门 6 秒rn operation_id = 1 door_id = 1 address_type = 2 door_action = 6 ret = self.commpro.ControlDevice(self.hcommpro, operation_id, door_id, address_type, door_action, 0, ‘’) rn<em>c#</em>:使编号为 2 的门常开rn int ret = 0;rn int operid = 1;rn int doorid = 2;rn int addresstype = 0; rnint dooraction = 255; rnret = ControlDevice(h, operid, doorid, addresstype, dooraction, 0, ""); rnrn我是C#,我<em>调用</em>报错,参数在调试窗口显示也都没错[img=https://img-bbs.csdn.net/upload/201805/25/1527214330_259285.jpg][/img] 求大神指导
调用ZLG600Lib.dl,报错尝试读取写入保护内存。这通常指示其他内存已损坏
刚接手到一个ic卡项目,需要用到新的协议,不过刚<em>调用</em>这个ZLG600Lib.<em>dll</em>就报<em>尝试</em><em>读取</em>或<em>写入</em>受<em>保护</em>的<em>内存</em>。这<em>通常</em><em>指示</em>其他<em>内存</em><em>已损坏</em>。不知道有没有大佬知道解决方法rn[img=https://img-bbs.csdn.net/upload/201804/18/1524017235_618539.png][/img]rn[img=https://img-bbs.csdn.net/upload/201804/18/1524017247_826183.png][/img]rnrn文档和一个c++的demo放在下面的百度云里面,ZLG600Lib.<em>dll</em>在ZLG600A_pcdemo.zip里面rn链接:https://pan.baidu.com/s/1up3z-YpfJ0NJD8O-QOz30Q 密码:tpbq
【急】C# 调用dll 尝试读取写入保护内存。这通常指示其他内存已损坏。【100分】
我要<em>调用</em>VC6写的一个<em>dll</em>,其C++函数声明为rnvoid WINAPI AvzGetImage (unsigned short uDeviceID, unsigned char *pImage, unsigned short FingerOn)rn我在C#中<em>调用</em>rn [DllImport("AvzScanner.<em>dll</em>", EntryPoint="AvzGetImage")]rn public static extern bool AvzGetImage(UInt32 uDeviceID, ref Byte[] pImage,UInt16 FingerOn);rn怎么试都不对!!什么stringbuilder啊,什么IntPtr?总是报<em>尝试</em><em>读取</em>或<em>写入</em>受<em>保护</em>的<em>内存</em>。这<em>通常</em><em>指示</em>其他<em>内存</em><em>已损坏</em>rnrnrn------------------------------------------------------rn悬赏大侠们解决!
C# 尝试读取写入保护内存。这通常指示其他内存已损坏
[img=https://img-bbs.csdn.net/upload/201310/10/1381395565_288257.jpg][/img]rn[color=#FF0000][size=24px]问题代码如下:[/size][/color]rn[code=csharp]rnrnusing System;rnusing System.Collections.Generic;rnusing System.Linq;rnusing System.Text;rnusing System.Runtime.InteropServices;rnrnnamespace Dwmrnrn class Dwmrn rn [DllImport("user32.<em>dll</em>", EntryPoint = "FindWindowA")] // 取窗口句柄rn private static extern int FindWindow(string ClassName,string TextName);rn [DllImport("gdi32.<em>dll</em>", EntryPoint = "GetDeviceCaps")] // 取设备场景信息rn private static extern int GetDeviceCaps(int Device,int Value);rn [DllImport("user32.<em>dll</em>", EntryPoint = "GetDesktopWindow")] // 取屏幕句柄rn private static extern int GetDesktopWindow();rn [DllImport("user32.<em>dll</em>", EntryPoint = "ReleaseDC")] // 释放设备场景rn private static extern int ReleaseDC(int hwnd,int hdc);rn [DllImport("user32.<em>dll</em>", EntryPoint = "GetDC")] // 取设备场景rn private static extern int GetDC(int hwnd);rn [DllImport("user32.<em>dll</em>", EntryPoint = "GetWindowLongA")] // 从指定窗口的结构中取得信息rn private static extern int GetWindowLongA(int hwnd,int Gwl);rn [DllImport("user32.<em>dll</em>", EntryPoint = "SetLayeredWindowAttributes")] // 窗口透明rn private static extern int SetLayeredWindowAttributes(int Hwnd,int crKey,int bAlpha,int dwFlags);rn [DllImport("dwmapi.<em>dll</em>",EntryPoint="DwmExtendFrameIntoClientArea")] // Dwm 风格rn private static extern int DwmExtendFrameIntoClientArea(int hwnd, Margin Margin);rn [DllImport("user32.<em>dll</em>", EntryPoint = "SetWindowLongA")] // 在窗口结构中为指定的窗口设置信息rn private static extern int SetWindowLongA(int Hwnd, int nIndex, int dwNewLong);rn [DllImport("kernel32.<em>dll</em>", EntryPoint = "GetVersionExA")] // 取系统版本信息rn private static extern int GetVersionExA(OSVERSIONINFO OSVERSIONINFO);rn public struct Margin // 范围rn rn public int Left;rn public int Right;rn public int Top;rn public int Bottom;rn rn public struct OSVERSIONINFO // 版本信息rn rn public int dwOSVersionInfoSize;rn public int dwMajorVersion ;rn public int dwMinorVersion ;rn public int dwBuildNumber ;rn public int dwPlatformId;rn public string []szCSDVersion;rn rn public struct DeviceCapsInfo // 显示模式信息rn rn public int HORZRES;rn public int VERTRES ;rn public int BITSPIXEL ;rn public int VREFRESH ;rn rn private const int VREFRESH = 116; // 刷新频率rn private const int HORZRES = 8; // 宽度rn private const int VERTRES = 10; // 高度rn private const int BITSPIXEL = 12; // 颜色位数rn public int GetHwnd(string TextName,string ClassName) // 取窗口句柄rn rn return FindWindow(ClassName,TextName);rn rn public bool isosvalue(int value)rn rn OSVERSIONINFO OSVERSIONINFO = new OSVERSIONINFO();rn OSVERSIONINFO.dwOSVersionInfoSize = 148;rn GetVersionExA(OSVERSIONINFO);rn if (OSVERSIONINFO.dwMajorVersion >= value)rn rn return true;rn rn elsern rn return false;rn rn rn public DeviceCapsInfo GetDesktopInfo() // 取当前显示模式rn rn int hwnd = GetDesktopWindow();rn int hdc = GetDC(hwnd);rn int currHres = GetDeviceCaps(hdc, HORZRES);rn int currVres = GetDeviceCaps(hdc, VERTRES);rn int currBPP = GetDeviceCaps(hdc, BITSPIXEL);rn int currVFreq = GetDeviceCaps(hdc, VREFRESH);rn DeviceCapsInfo info = new DeviceCapsInfo();rn info.HORZRES = currHres;rn info.VERTRES = currVres;rn info.VREFRESH = currVFreq;rn info.BITSPIXEL = currBPP;rn return info;rn rn public int Open_Dmc(int 窗口句柄,int 色彩位率,bool 分层窗体,int 分离颜色值,int 分离透明度,int 分离方式,bool 默认参数,int Top,int Left,int Right,int Bottom,bool isopen)rn rn DeviceCapsInfo dc=GetDesktopInfo();rn Margin Margin = new Margin();rn int 宽度=dc.HORZRES; // 宽度rn int 高度=dc.VERTRES; // 高度rn int 刷新略=dc.VREFRESH; // 刷新频率rn int 位数=dc.BITSPIXEL; // 颜色位数rn if (色彩位率 == 位数)rn rn int 局变_风格=GetWindowLongA (窗口句柄, -20);rn 局变_风格=(局变_风格|524288);rn SetWindowLongA (窗口句柄, -20, 局变_风格);rn if(分层窗体==true)rn rn SetLayeredWindowAttributes(窗口句柄,分离颜色值,分离透明度,分离方式); // 1或3 可正常用,4 控件消失rn rn if (默认参数 != true)rn rn Margin.Top = Top;rn Margin.Left = Left;rn Margin.Right = Right;rn Margin.Bottom = Bottom;rn rn elsern rn Margin.Top = -1;rn Margin.Left = -1;rn Margin.Right = -1;rn Margin.Bottom = -1;rn rn if (isopen==true)rn rn return DwmExtendFrameIntoClientArea(窗口句柄, Margin);rn // 问题出现在这一句话,rn // 这句话的功能表示 开启透明(win8 peek,win7 Aero)效果rn // 必须提供 struct 数据类型 非 enum 类型rn // 但是若提供数据类型进去,就会报错,略过窗口就无法透明rn rn return 0;rn rn return -1;rn rn rnrn[/code]
c#尝试读取写入保护内存。这通常指示其他内存已损坏 怎么解决
/// rn /// byte数组转结构rn /// rn /// byte数组rn /// 结构类型rn /// 转换后的结构rn public static object BytesToStruct(byte[] bytes, Type type)rn rn //得到结构的大小rn int size = Marshal.SizeOf(type);rn // Log(size.ToString(), 1);rn //byte数组长度小于结构的大小 不能转换则返回 nullrn if (size > bytes.Length)rn rn //返回空rn return null;rn rn //分配结构大小的<em>内存</em>空间rn IntPtr structPtr = Marshal.AllocHGlobal(size);rn //将byte数组拷到分配好的<em>内存</em>空间rn Marshal.Copy(bytes, 0, structPtr, size);rn //将<em>内存</em>空间转换为目标结构rn object obj = Marshal.PtrToStructure(structPtr, type);rn //释放<em>内存</em>空间rn Marshal.FreeHGlobal(structPtr);rn //返回结构rn return obj;rn rnrnrnrn出现错误:<em>c#</em><em>尝试</em><em>读取</em>或<em>写入</em>受<em>保护</em>的<em>内存</em>。这<em>通常</em><em>指示</em>其他<em>内存</em><em>已损坏</em>。rn是怎么回事,该怎么改呢?
高手!C# webBrowser尝试读取写入保护内存。这通常指示其他内存已损坏
在做一个C# WinForm应用程序,里面添加了webBrowser控件,但有时提示:“<em>尝试</em><em>读取</em>或<em>写入</em>受<em>保护</em>的<em>内存</em>。这<em>通常</em><em>指示</em>其他<em>内存</em><em>已损坏</em>。”的错误,有时又非常正常,真是找不原因,搜索了也没找的,高手救救
C# 尝试读取写入保护内存。这通常指示其他内存已损坏
listBox1.Items.Clear();rn API.PROCESSENTRY32 tag = new API.PROCESSENTRY32();rn tag.dwSize = System.Runtime.InteropServices.Marshal.SizeOf(tag);rn IntPtr ptr = API.FindWindow(0, "Warcraft III");rn API.GetWindowThreadProcessId(ptr, ref lpwdProcessId);rn IntPtr hwnd = API.CreateToolhelp32Snapshot(0x4, lpwdProcessId);rn if (API.Process32First(hwnd,ref tag))rn rn object s = (object)tag.th32ProcessID;rn listBox1.Items.Add(s);rn while [color=#FF0000](API.Process32Next(hwnd,ref tag))[/color]这一步就出错了rn rn object k = (object)tag.th32ProcessID;rn listBox1.Items.Add(k);rn rn rnrn 结构体rn [StructLayout(LayoutKind.Sequential)]rn public struct PROCESSENTRY32rn rn public int dwSize; //结构的大小 如果你没用PROCESSENTRY32中的成员dwSize初始化,pricess32First将会<em>失败</em>。)rn public int cntUsage;//此进程的引用计数rn public int th32ProcessID;//这个就是任务管理器里面的进程的PID,打开任务管理器--查看---选择列---PID(勾选)就可以显示进程的标示符(PID)rn public ulong th32DefaultHeapID;//进程默认堆IDrn public int th32ModuleID;// 进程模块IDrn public int cntThreads;//此进程开启的线程计数rn public int th32ParentProcessID;//父进程的IDrn public int pcPriClassBase;//线程优先权rn public int dwFlags;rn [MarshalAs(UnmanagedType.ByValArray, SizeConst = 260)]rn public char[] szExeFile;//进程全名rn rn 高手帮我解决下
C#调C++DLL尝试读取写入保护内存。这通常指示其他内存已损坏
C#代码:rn [DllImport("SVM_DLL.<em>dll</em>", EntryPoint = "ImportantMain", CallingConvention = CallingConvention.Cdecl)]rn public static extern void ImportantMain(double[] OPtion_Parameter, double[] OPtion_Alpha, double[] B0, double[] Option_MaxError);rnrnrn [DllImport("SVM_DLL.<em>dll</em>", EntryPoint = "predictY", CallingConvention = CallingConvention.Cdecl)]rn public static extern void predictY(double[] OPtion_Parameter, double[] OPtion_Alpha, double[] B0, double[,] X2, double[] Y2);rnrnrn FileStream fs = new FileStream("C:\\Users\\Cwq\\Desktop\\处理后的遥感程序\\ForestAppImageClassify\\meanBandValueArr.txt", FileMode.Open, FileAccess.Write, FileShare.ReadWrite);rn StreamWriter sw = new StreamWriter(fs);rn double[] Option_MaxError = new double[1];rn //double[,] KK = new double[30, 300];rn double[] Y2 = new double[1];rn double[] OPtion_Parameter = new double[6];rn double[] OPtion_Alpha = new double[30];rn double[] B0 = new double[1];rn double[,] X2 = new double[300,300];rn int iso = 0;rn ReadImage.ImportantMain(OPtion_Parameter, OPtion_Alpha, B0, Option_MaxError);rn for (int i = 0; i < 6; i++)rn sw.Write(OPtion_Parameter[i] + " ");rn sw.WriteLine();rn for (int i = 0; i < 30; i++)rn sw.Write(OPtion_Alpha[i] + " ");rn sw.WriteLine();rn sw.WriteLine(" GF3 " + " GF4 " + " GF4/GF3 " + " (GF4-GF3)/(GF4+GF3) " + " 预测值Y2 " + " B0");rnrn X2[0, 0] = (double)pixelValueArr[2] / 255.0;rn X2[0, 1] = (double)pixelValueArr[3] / 255.0;rn X2[0, 2] = (double)(pixelValueArr[3] / pixelValueArr[2]) / 2.16;rn X2[0, 3] = (double)((pixelValueArr[3] - pixelValueArr[2]) / (pixelValueArr[3] + pixelValueArr[2])) / 0.36;rn System.Diagnostics.Stopwatch stopwatch = new Stopwatch();rn stopwatch.Start(); // 开始监视代码rn ReadImage.predictY(OPtion_Parameter, OPtion_Alpha, B0, X2, Y2);//DLL<em>调用</em>rn程序在执行大约十分钟时最后一行 ReadImage.predictY(OPtion_Parameter, OPtion_Alpha, B0, X2, Y2);//DLL<em>调用</em>rn就会出现 “<em>尝试</em><em>读取</em>或<em>写入</em>受<em>保护</em>的<em>内存</em>。这<em>通常</em><em>指示</em>其他<em>内存</em><em>已损坏</em>。” C#源程序需要多次<em>调用</em>C++DLL<em>读取</em>影像图。刚开始可以执行的,但是就在运行一段时间后就会出现这个问题。rnC++中的DLL rnextern"C"_declspec(<em>dll</em>export)void predictY(double OPtion_Parameter[6],double OPtion_Alpha[30],double B0[1],static double X2[300][300],static double Y2[1] )rnrn想问下C++中的double型一维数组和C#中的double一维数组大小一样吗,二维呢????是不是我的数据类型对应不正确???rnrn
?C#大神求解 尝试读取写入保护内存。这通常指示其他内存已损坏
代码功能就是将CSV文件数据导入到ACCESS数据库里。rn在调试过程中运行一次不会报错,但是连续运行多次就出错(次数不定,有时3次有时5次)[img=https://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/001/face/1.gif][/img]rn运行到 OleDbConnection.open() 时会报错“<em>尝试</em><em>读取</em>或<em>写入</em>受<em>保护</em>的<em>内存</em>。这<em>通常</em><em>指示</em>其他<em>内存</em><em>已损坏</em>。”[img=https://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/001/face/3.gif][/img]rn网上查过一些类似问题,说是改目标平台为“Anycpu”能解决,但是亲测<em>失败</em>(倒是比X86能多运行几次。。。)rn环境 win7 32位,vs2010,framework 4.5 版本 rn本人初学者,希望大神们解释的尽量通俗点。谢谢[img=https://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/001/face/83.gif][/img]rnrn错误描述如下:rn未处理 System.AccessViolationExceptionrn HResult=-2147467261rn Message=<em>尝试</em><em>读取</em>或<em>写入</em>受<em>保护</em>的<em>内存</em>。这<em>通常</em><em>指示</em>其他<em>内存</em><em>已损坏</em>。rn Source=System.Datarn StackTrace:rn 在 System.Data.OleDb.DataSourceWrapper.InitializeAndCreateSession(OleDbConnectionString constr, SessionWrapper& sessionWrapper)rn 在 System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection)rn 在 System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)rn 在 System.Data.ProviderBase.DbConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)rn 在 System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions)rn 在 System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)rn 在 System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)rn 在 System.Data.ProviderBase.DbConnectionInternal.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)rn 在 System.Data.OleDb.OleDbConnection.Open()rn 在 GXCTV1.FMWTK.insClk(String CLkPathNam) 位置 C:\Users\Administrator.SKY-20170415EAI\Documents\Visual Studio 2010\Projects\GXCTV1\GXCTV1\FMWTK.cs:行号 866rn 在 GXCTV1.FMWTK.insWtk_Click(Object sender, EventArgs e) 位置 C:\Users\Administrator.SKY-20170415EAI\Documents\Visual Studio 2010\Projects\GXCTV1\GXCTV1\FMWTK.cs:行号 485rn 在 System.Windows.Forms.Control.OnClick(EventArgs e)rn 在 System.Windows.Forms.Button.OnClick(EventArgs e)rn 在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)rn 在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)rn 在 System.Windows.Forms.Control.WndProc(Message& m)rn 在 System.Windows.Forms.ButtonBase.WndProc(Message& m)rn 在 System.Windows.Forms.Button.WndProc(Message& m)rn 在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)rn 在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)rn 在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)rn InnerException: rn
C# 尝试读取写入保护内存。这通常指示其他内存已损坏
rn//声明rntypedef int SMTK_INT;rntypedef unsigned int SMTK_UINT;rntypedef unsigned long SMTK_DWORD;rntypedef unsigned long SMTK_HANDLE;rnrnrn//结构rnrntypedef struct _tagSmtkChannel /* 通道 */rnrn SMTK_INT nID; /* 通道号 */rn SMTK_INT nType; /* 见(通道类型定义) */rn char szName[StringLength]; /* 通道名称 */rn SmtkChannel, *PSmtkChannel;rnrntypedef struct _tagSmtkDeviceResource /* 设备资源 */rnrn char szPUID[16]; /* PUID */rn char szName[StringLength]; /* 设备名称 */rn SMTK_INT nChannelCount; /* 通道数量 */rn SmtkChannel stChannel[1]; /* 通道数组 */rn SmtkDeviceResource, *PSmtkDeviceResource;rnrnrn//方法rnrn/**************** 设备配置接口 ***************/rnSMTK_INT SMTK_GetDeviceResource(SMTK_HANDLE hHandle, PSmtkDeviceResource pDeviceResource, SMTK_DWORD dwBufferLength);rnrnrn//<em>调用</em>rnm_sWndPair[m_iWndPair].hSmtk 指设备信息rnm_sWndPair[m_iWndPair].hSmtk = SMTK_Login(csUser, csPas, szBufIP, 3456);rnrnrn BYTE Buffer[1024] = 0;rn SmtkDeviceResource* pSmtkDeviceResource = (SmtkDeviceResource*)Buffer;rn SMTK_INT iGet = SMTK_GetDeviceResource(m_sWndPair[m_iWndPair].hSmtk, pSmtkDeviceResource, 1024);rn if(iGet != 0)rn rn MessageBox("获取设备资源<em>失败</em>!");rn return;rn rnrnrnrn下面是我的rnrnrn /// rn /// 设备资源rn /// rn public struct SmtkDeviceResourcern rn /// rn /// char szPUID[16]; szPUIDrn /// rn public string szPUID;rnrn /// rn /// char szPUID[32]; szName 设备名称 rn /// rn public string szName;rn /// rn /// 通道数量 rn /// rn public int nChannelCount;rn /// rn /// 通道数组rn /// rn ///[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]rn public SmtkChannel[] stChannel;rn rnrn ///通道信息rn public struct SmtkChannelrn rn /// rn /// 通道号rn /// rn public int nID;rnrn /// rn /// 见(通道类型定义)rn /// rn public int nType;rnrn /// rn /// char szPUID[32]; szName 通道名称 rn /// rn public string szName;rn rnrnrnrn /// rn /// 获取设备信息rn /// rn /// rn /// rn /// rn /// [DllImport("SMTK.<em>dll</em>")]rn public static extern int SMTK_GetDeviceResource(IntPtr hHandle, IntPtr pDeviceResource, int dwBufferLength);rnrnrn//<em>调用</em>rn rnrn byte[] vBuffer = new byte[1024];rn IntPtr vAddress = Marshal.UnsafeAddrOfPinnedArrayElement(vBuffer, 0); // 取得<em>内存</em>首地址rnrn int cmd = SmartSDK.SMTK_GetDeviceResource(m_hSmtk, vAddress, vBuffer.Length);rnrn SmtkDeviceResource entries = (SmtkDeviceResource)BytesToStruct(vBuffer, typeof(SmtkDeviceResource));rnrn报 C# <em>尝试</em><em>读取</em>或<em>写入</em>受<em>保护</em>的<em>内存</em>。这<em>通常</em><em>指示</em>其他<em>内存</em><em>已损坏</em>rn求高人指教rnrn
c#尝试读取写入保护内存。这通常指示其他内存已损坏
排除代码的问题,在我的电脑上执行正常 在别的电脑上执行就爆出这个错误 rn我们俩个电脑 系统 位数全部一样 可能是什么原因呢?
尝试读取写入保护内存。这通常指示其他内存已损坏。"">c#调c++dll"尝试读取写入保护内存。这通常指示其他内存已损坏。"
extern "C" __declspec(<em>dll</em>export) int Init(string dbPath ,BOOL isShowDbgInfo = TRUE);rn这个是c++接口,我的引用如下:rn[DllImport(@"lib\FPLib\FPMFCDLL.<em>dll</em>", CallingConvention = CallingConvention.Cdecl)]rnpublic static extern int Init(string dbPath, bool isShowDbgInfo = true);rn <em>调用</em>:Init("xxx");时报错:<em>尝试</em><em>读取</em>或<em>写入</em>受<em>保护</em>的<em>内存</em>。这<em>通常</em><em>指示</em>其他<em>内存</em><em>已损坏</em>。rn不知道是什么问题?rn我这样改了,还是报错,如下:rn[DllImport(@"lib\FPLib\FPMFCDLL.<em>dll</em>", CallingConvention = CallingConvention.Cdecl)]rnpublic static extern int Init(IntPtr dbPath, bool isShowDbgInfo = true);rnIntPtr ptrIn = Marshal.StringToHGlobalAnsi(dbPath);rnIntPtr ptrRet = Marshal.AllocHGlobal(ptrIn);rnint re = SDK_Fingerprint.Init(ptrRet);rnMarshal.FreeHGlobal(ptrRet);
C# dllimport 出错 尝试读取写入保护内存。这通常指示其他内存已损坏
delphi定义如下:rn//取点状态rn//成功:0rn//<em>失败</em>:非零rnfunction Aukit_DCU8004_GetDotStatusrn (rn hCom:THandle;rn DcuID:integer;rn var rDotStatus:TDCU8004_GetDotStatus;rn ): integer; stdcall;rn external 'DCU8004.<em>dll</em>' name 'Aukit_DCU8004GetDotStatus';rn//设置点状态rn//成功:0rn//<em>失败</em>:非零rnfunction Aukit_DCU8004_SetDotStatusrn (rn hCom:THandle;rn DcuID:integer;rn const rDotStatus:TDCU8004_SetDotStatus;rn ): integer; stdcall;rn external 'DCU8004.<em>dll</em>' name 'Aukit_DCU8004SetDotStatus';rnrnC#<em>调用</em>如下:rn[DllImport("DCU8004.<em>dll</em>", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]rn public static extern int Aukit_DCU8004_GetDotStatus(IntPtr hCom, int DcuID,ref TDCU8004_DotStatusOne[] dotstatus);rnrn [DllImport("DCU8004.<em>dll</em>", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]rn public static extern int Aukit_DCU8004_SetDotStatus(IntPtr hCom, int DcuID, TDCU8004_DotStatusOne[] dotstatus);rnrnrn问题如题.
halcon算子实现视频显示和处理的例子
用视觉系统开发的halcon软件提供的算子实现视频显示和处理。
WinForm:尝试读取写入保护内存。这通常指示其他内存已损坏
[code=css]rn DALFactory.MultiMs.bulidSmil(Application.StartupPath + @"\" + FL + "\\", fName + ".smil", alimge, altxt, alsound, alTime);rn string mmsInfo = DALFactory.MultiMs.readfilekb(Application.StartupPath + @"\" + FL);rn label16.Text = "您制作的彩信大小为" + mmsInfo.ToString() + ";彩信不能超过" + intSupportKB.ToString() + "kb!";rn//没什么运行到label16.Text...这个位置就会报出异常提示“<em>尝试</em><em>读取</em>或<em>写入</em>受<em>保护</em>的<em>内存</em>。。。”,并且在这句的前面如果执行一次MessageBox.show("1"); 异常就不会出现rn string SubSize = mmsInfo.Substring(0, mmsInfo.Length - 2);rn MMSsize = Convert.ToDecimal(SubSize);rn[/code]rnrnrn针对上述问题,请教各位,在下新人!谢谢
关于“尝试读取写入保护内存。这通常指示其他内存已损坏”的问题
写了个程序,开始用本地数据库没发现问题,rn后来改成了公司服务器上的数据库就出现了“<em>尝试</em><em>读取</em>或<em>写入</em>受<em>保护</em>的<em>内存</em>。这<em>通常</em><em>指示</em>其他<em>内存</em><em>已损坏</em>”的报错rn代码是没有问题的,在公司其他机器上运行过,没有问题。rn也就是说是我机器环境设置的问题(大概),烦恼好久,有了解的求教下rn代码是基本的创建sqlConnection:rnusing (SqlConnection sc = new SqlConnection("Data Source=192.168.1.8;Initial Catalog=XXXXX;Persist Security Info=True;User ID=sa;Password=XXXXXXXXX"))rn rn sc.Open();rn //创建临时表rn SqlCommand comm = null;rn ......rn rn在sc.Open();那里报错的
错误“尝试读取写入保护内存。这通常指示其他内存已损坏
做的是软件二次开发,提供的DLL文件本来是供C++二次开发用的,但我使用的编程软件是vb.netrnrn<em>dll</em>文件函数手册(供C++使用的):rn[code=c]rntypedef structrnrnrnLONG cfHeight; //字符高度rnLONG cfWidth; //字符宽度rnLONG cfWeight; //字符粗细rnLONG cfSpacing; //字符间距rnBOOL cfItalic; //斜体rnBOOL cfUnderline; //下划线rnBOOL cfStrikeOut; //删除线rnBOOL bTransparent; //透明rnCOLORREF cfBkColor; //背景色 rnCOLORREF cfTextColor; //前景色rnTCHAR cfFaceName[32]; //字体名rnrnOSDPARAM;rn/设置视频捕获时间、日期叠加,在VCASetVidCapDateTimeOSDPARAM()函数设置后<em>调用</em>有效rnBOOL WINAPI VCASetVidCapDateTimeOSD( DWORD dwCard, BOOL bEnableOSD, POINT& ptTopLeft);rn//设置视频捕获字幕叠加rnBOOL WINAPI VCASetVidCapDateTimeOSDParam( OSDPARAM* pOSDParm );rn[/code]rnrnvb.net使用该DLL文件:rn先将以上代码转为vb.net代码rn[code=vb]rnPublic Structure OSDParamrn Dim cfHeight As Longrn Dim cfWidth As Longrn Dim cfWeight As Longrn Dim cfSpacing As Longrn Dim cfItalic As Booleanrn Dim cfUnderline As Booleanrn Dim cfStrikeOut As Booleanrn Dim bTransparent As Booleanrn Dim cfBkColor As Colorrn Dim cfTextColor As Colorrn Dim cfFaceName() As ByternrnEnd Structurern '设置视频时间、日期叠加参数rn Declare Function VCASetVidCapDateTimeOSDParam Lib "Sa7134Capture.<em>dll</em>" _rn (ByVal pOSDParam As OSDParam) As Booleanrn '设置视频时间、日期叠加rn Declare Function VCASetVidCapDateTimeOSD Lib "Sa7134Capture.<em>dll</em>" _rn (ByVal dwCard As Long, ByVal bEnableOSD As Long, ByVal ptTopLeft As Point) As Booleanrn[/code]rnrn<em>调用</em>函数:rn[code=vb]rnrn Public OsdParameter As OSDParamrn Public OsdTimepoint As Pointrnrn'设置录像osd参数(本sdk相关的osd参数只对录像osd生效,预览osd自己来创建)rn OsdParameter.cfHeight = 15 ' //字符高度rn OsdParameter.cfWidth = 12 ' //字符宽度rn OsdParameter.cfWeight = 10 ' //字符粗细rn OsdParameter.cfSpacing = 0 ' //字符间距rn OsdParameter.cfItalic = False ' //斜体rn OsdParameter.cfUnderline = False ' //下划线rn OsdParameter.cfStrikeOut = False ' //删除线rn OsdParameter.bTransparent = Truern OsdParameter.cfBkColor = System.Drawing.Color.FromArgb(255, 255, 255) ' //背景色rn OsdParameter.cfTextColor = System.Drawing.Color.FromArgb(0, 0, 0) ' //前景色rn ReDim OsdParameter.cfFaceName(31)rn OsdParameter.cfFaceName(0) = 0rnrn OsdTimepoint.X = 10rn OsdTimepoint.Y = 20rnrn VCASetVidCapDateTimeOSDParam(OsdParameter)rn VCASetVidCapDateTimeOSD(i, 1, OsdTimepoint)rn[/code]rnrn当执行到VCASetVidCapDateTimeOSDParam(OsdParameter)就会出现错误“<em>尝试</em><em>读取</em>或<em>写入</em>受<em>保护</em>的<em>内存</em>。这<em>通常</em><em>指示</em>其他<em>内存</em><em>已损坏</em>”。rn一直卡死在这,求大神指教啊!!!
为啥会出现:尝试读取写入保护内存。这通常指示其他内存已损坏
[code=csharp] public static string ToString(cef_string_t* obj)rn rn if (obj == null) return null;rn rn return new string((char*)obj->_str, 0, (int)obj->_length);rn [/code]
尝试读取写入保护内存,这通常指示其他内存已损坏
RT,rn 程序运行一会后就报错,rnstatic class Programrn rn /// rn /// 应用程序的主入口点。rn /// rn [STAThread]rn static void Main()rn rn Application.EnableVisualStyles();rn Application.SetCompatibleTextRenderingDefault(false);rn [b]Application.Run(new Form1());[/b]rn粗体字提示<em>尝试</em><em>读取</em>或<em>写入</em>受<em>保护</em>的<em>内存</em>,这<em>通常</em><em>指示</em>其他<em>内存</em><em>已损坏</em>rn可能是什么原因?
尝试读取写入保护内存通常指示其他内存已损坏
VS2008 C++控制台程序 rnrnchar *Pstr = "";rnMEMORYSTATUS mem;rnGlobalMemoryStatus(&mem);rnint Phy = mem.dwTotalPhys/1024/1024/<em>100</em>0;rnsprintf(Pstr, " %d GB", Phy);rninfo["memo"] = Pstr;rnrn程序生成通过,运行之后就出现这个错误rnrn<em>尝试</em><em>读取</em>或<em>写入</em>受<em>保护</em>的<em>内存</em> 这<em>通常</em><em>指示</em>其他<em>内存</em><em>已损坏</em>rnrn后面还有一些字符串处理函数也有同样的错误rnrn不知道是什么情况啊,应该如何解决?
异常求助.尝试读取写入保护内存。这通常指示其他内存已损坏
关于C#<em>调用</em>C++的DLL时出现的问题rnrnC++ code:rnrn[code=C/C++]rn结构原型:rntypedef struct ik_longshine_person_info_srnrn rn int person_id;rn char person_name[128]; rn char employee_num[128]; rn int iris_enroll_flag; rn int sex; rn char blood_type[20];rn char birthday[20]; rn char id_card[64]; rn char phone[64]; rn char address[256]; rn char zip_code[20]; rn char email_addr[128]; rnik_longshine_person_info_t;rnrntypedef struct ik_longshine_person_array_srnrn int person_count;rn ik_longshine_person_info_t *persons;rnik_longshine_person_array_t;rnrn,// 输入参数 ik_longshine_person_info_t *pPerson , 输出参数 local_person, server_person中的persons指向的<em>内存</em>需要<em>调用</em>ik_as_free来释放rn rnint STDCALL ik_as_sync_person (IK_LS_ATTEND_SERVER_HANDLE handle, ik_longshine_person_info_t *pPerson, int nPersonCount,ik_longshine_person_array_t *local_person,ik_longshine_person_array_t *server_person);[/code]rnrn下边是我写的代码,大家帮忙看看错在哪里谢谢了rnrn[code=C#]rn[DllImport("IKLongShine-2_0_0.<em>dll</em>")]rnpublic extern unsafe static int ik_as_sync_person(IntPtr handle,ik_longshine_person_info_t[] pPerson,int nPersonCount,out ik_longshine_person_array_t local_person,out ik_longshine_person_array_t server_person);rnrn [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]rn public struct ik_longshine_person_info_trn rn //必填项rn public int person_id; rn [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]rn public string person_name; rn [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]rn public string employee_num; rn public int iris_enroll_flag; rn //选填项rn public int sex; rn [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]rn public string blood_type; rn [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]rn public string birthday; rn [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)]rn public string id_card; rn [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)]rn public string phone; rn [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]rn public string address; rn [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]rn public string zip_code; rn [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]rn public string email_addr; rn rn rnrn [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]rn public struct ik_longshine_person_array_trn rn [MarshalAs(UnmanagedType.SafeArray)]rn public ik_longshine_person_info_t[] persons; rn public int person_count; rn rnprivate void btnTongbu_Click(object sender, EventArgs e)rn rn rn ConnDB.Constr = readINI();rn ConnDB.Open();rn string ip = "127.0.0.1";rn IntPtr handle = ik_as_connect(ip, 9988, <em>100</em>0);rn MessageBox.Show(handle.ToString());rn ik_longshine_person_info_t[] persons = new ik_longshine_person_info_t[1750];rn ik_longshine_person_array_t local;rn ik_longshine_person_array_t server;rn DataSet ds = new DataSet();rn ds = ConnDB.GetData("select irisID,name,serialNum from tb_emp_info"); rn DataTable dt = ds.Tables[0];rn int count = 0;rn for (int i = 0; i < dt.Rows.Count;i++ )rn rn persons[i].person_id = Convert.ToInt32(dt.Rows[i]["irisID"]);rn persons[i].person_name = dt.Rows[i]["name"].ToString();rn persons[i].employee_num = dt.Rows[i]["serialNum"].ToString();rn persons[i].iris_enroll_flag = 0;rn count = i;rn rn int tongbuMsg = ik_as_sync_person(handle, persons, count, out local, out server); //此处报异常rn rn MessageBox.Show(tongbuMsg.ToString());rn ik_longshine_person_info_t[] localPerson = local.persons;rn int localCount = local.person_count;rn ik_longshine_person_info_t[] serverPerson = server.persons;rn int serverCount = server.person_count;rn int delMsg = ik_as_del_person(handle, serverPerson, serverCount);rn MessageBox.Show(delMsg.ToString());rn ik_as_close(handle);rn rn rnrnrnrnrn[/code]rnrnrnik_as_connect为连接服务器函数,如果服务器没有连接正常 就会出现这个异常,现在服务器没问题,返回的句柄也正确 怎么还会出现异常呢rnrn异常信息:rn 在 MainFrm.ik_as_sync_person(IntPtr handle, ik_longshine_person_info_t[] pPerson, Int32 nPersonCount, ik_longshine_person_array_t& local_person, ik_longshine_person_array_t& server_person)rn 在 MainFrm.btnTongbu_Click(Object sender, EventArgs e) 位置 MainFrm.cs:行号 534rn
引入WINAPI,错误“尝试读取写入保护内存。这通常指示其他内存已损坏
做的是软件二次开发,提供的DLL文件本来是供C++二次开发用的,但我使用的编程软件是vb.netrnrn<em>dll</em>文件函数手册(供C++使用的):rn[code=c]BOOL WINAPI VCASetVidCapDateTimeOSD( DWORD dwCard, BOOL bEnableOSD, POINT& ptTopLeft);[/code]rnrnvb.net使用该DLL文件:rn先将以上代码转为vb.net代码rn[code=vb]Declare Function VCASetVidCapDateTimeOSD Lib "Sa7134Capture.<em>dll</em>" _rn (ByVal dwCard As Long, ByVal bEnableOSD As Long, ByRef ptTopLeft As Point) As Boolean[/code]rnrn<em>调用</em>函数:rn[code=vb]rn Public OsdTimepoint As Pointrn OsdTimepoint.X = 10rn OsdTimepoint.Y = 20rnrn VCASetVidCapDateTimeOSD(0, 1, OsdTimepoint)rn[/code]rnrn当执行到VCASetVidCapDateTimeOSD(0, 1, OsdTimepoint)就会出现错误“<em>尝试</em><em>读取</em>或<em>写入</em>受<em>保护</em>的<em>内存</em>。这<em>通常</em><em>指示</em>其他<em>内存</em><em>已损坏</em>”。是不是ByRef和ByVal的问题,我将所有的ByVal换成ByRef的话,则VCASetVidCapDateTimeOSD的返回值为False,说明执行<em>失败</em>。rn求大神指教啊!!!
尝试读取写入保护内存。这通常指示其他内存已损坏。。
C#通过oledb方式在win2003上连接sybase数据库的时候报这个错,rn但是在xp上连接sybase数据库的时候就没这个问题。win2003上pb是可以连接上sybase数据库的。rnrn连接字符串是:provider=Sybase.ASEOLEDBProvider;Server Name=...(省略).rn求解
access 尝试读取写入保护内存。这通常指示其他内存已损坏
这是我的sql语句: select top 16 multiple_id, multiple_subject, trainee_name, difficulty, given_time, section_id from multiple_question_info as A, trainee_info as B where subject_id = 24 and A.trainee_id = B.trainee_id and is_multiple = 0 and A.is_deleted = 0 and multiple_id <> 2698 and multiple_id <> 2697 and multiple_id <> 2696 and multiple_id <> 2695 and multiple_id <> 2694 and multiple_id <> 2693 and multiple_id <> 2692 and multiple_id <> 2691 and multiple_id <> 2690 and multiple_id <> 2689 and multiple_id <> 2688 and multiple_id <> 2687 and multiple_id <> 2686 and multiple_id <> 2685 and multiple_id <> 2684 and multiple_id <> 2683 and multiple_id <> 2682 and multiple_id <> 2681 and multiple_id <> 2680 and multiple_id <> 2679 and multiple_id <> 2678 and multiple_id <> 2677 and multiple_id <> 2676 and multiple_id <> 2675 and multiple_id <> 2674 and multiple_id <> 2673 and multiple_id <> 2672 and multiple_id <> 2671 and multiple_id <> 2670 and multiple_id <> 2669 and multiple_id <> 2668 and multiple_id <> 2667 and multiple_id <> 2666 and multiple_id <> 2665 and multiple_id <> 2664 and multiple_id <> 2663 and multiple_id <> 2662 and multiple_id <> 2661 and multiple_id <> 2660 and multiple_id <> 2659 and multiple_id <> 2658 and multiple_id <> 2657 and multiple_id <> 2656 and multiple_id <> 2655 and multiple_id <> 2654 and multiple_id <> 2653 and multiple_id <> 2652 and multiple_id <> 2651 and multiple_id <> 2650 and multiple_id <> 2649 and multiple_id <> 2648 and multiple_id <> 2647 and multiple_id <> 2646 and multiple_id <> 2645 and multiple_id <> 2644 and multiple_id <> 2643 and multiple_id <> 2642 and multiple_id <> 2641 and multiple_id <> 2640 and multiple_id <> 2639 and multiple_id <> 2638 and multiple_id <> 2637 and multiple_id <> 2636 and multiple_id <> 2635 order by multiple_id desc rnrnrn执行完后就报错<em>尝试</em><em>读取</em>或<em>写入</em>受<em>保护</em>的<em>内存</em>。这<em>通常</em><em>指示</em>其他<em>内存</em><em>已损坏</em>。是不是我的sql语句太长了?因为我把sal语句改短一点后,就可以执行没有错误。 哪位大牛能指点一下 ,谢谢了!!!
请教关于“尝试读取写入保护内存。这通常指示其他内存已损坏”的问题
高手们好,我最近在做一个要用到条码打印机的BS系统,用的是立象的打印机,我做了一个button,用立象提供的DLL里的方法来操作打印,第一次点击button打印正常,但第二次点击就出现“<em>尝试</em><em>读取</em>或<em>写入</em>受<em>保护</em>的<em>内存</em>。这<em>通常</em><em>指示</em>其他<em>内存</em><em>已损坏</em>”,我觉得是DLL没有释放<em>内存</em>,但不知道怎么释放,网上很多都是用DLL里面的freeLibrary方法,但我用的这个DLL的API里面只有操作打印机的一些方法,没有freeLibrary方法。rn 另外我用CS模式的窗口来测试时,重复点击打印很多次都没有问题,不知道BS下重复打印出现的这个问题如何解决?还请大家多多指教。以下是我<em>调用</em>DLL的类的代码,button的点击事件会<em>调用</em>doPrint()方法:rn[code=C#]using System;rnusing System.Data;rnusing System.Configuration;rnusing System.Web;rnusing System.Web.Security;rnusing System.Web.UI;rnusing System.Web.UI.WebControls;rnusing System.Web.UI.WebControls.WebParts;rnusing System.Web.UI.HtmlControls;rnusing System.Runtime.InteropServices;rnrn/// rn/// <em>dll</em>Operator 的摘要说明rn/// rnpublic class <em>dll</em>Operatorrnrn const string szSavePath = "C:\\PPLB_Example.Prn";rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_Bar2d_Maxi(int x, int y, int cl, int cc, int pc, string data);rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_Bar2d_PDF417(int x, int y, int w, int v, int s, int c, int px,rn int py, int r, int l, int t, int o, string data);rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_Bar2d_PDF417_N(int x, int y, int w, int h, string para, string data);rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern void B_ClosePrn();rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_CreatePrn(int selection, string filename);rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_Del_Form(string formname);rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_Del_Pcx(string pcxname);rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_Error_Reporting(char option);rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern string B_Get_DLL_Version(int nShowMessage);rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_Get_DLL_VersionA(int nShowMessage);rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_Get_Pcx(int x, int y, string filename);rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_Initial_Setting(int Type, string Source);rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_Load_Pcx(int x, int y, string pcxname);rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_Open_ChineseFont(string path);rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_Print_Form(int labset, int copies, string form_out, string var);rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_Print_MCopy(int labset, int copies);rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_Print_Out(int labset);rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_Prn_Barcode(int x, int y, int ori, string type, int narrow,rn int width, int height, char human, string data);rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern void B_Prn_Configuration();rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_Prn_Text(int x, int y, int ori, int font, int hor_factor,rn int ver_factor, char mode, string data);rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_Prn_Text_Chinese(int x, int y, int fonttype, string id_name,rn string data);rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_Prn_Text_TrueType(int x, int y, int FSize, string FType,rn int Fspin, int FWeight, int FItalic, int FUnline, int FStrikeOut, string id_name,rn string data);rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_Prn_Text_TrueType_W(int x, int y, int FHeight, int FWidth,rn string FType, int Fspin, int FWeight, int FItalic, int FUnline, int FStrikeOut,rn string id_name, string data);rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_Select_Option(int option);rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_Select_Option2(int option, int p);rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_Select_Symbol(int num_bit, int symbol, int country);rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_Select_Symbol2(int num_bit, string csymbol, int country);rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_Set_Backfeed(char option);rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_Set_BMPSave(int nSave, string strBMPFName);rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_Set_Darkness(int darkness);rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_Set_DebugDialog(int nEnable);rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_Set_Direction(char direction);rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_Set_Form(string formfile);rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_Set_Labgap(int lablength, int gaplength);rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_Set_Labwidth(int labwidth);rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_Set_Originpoint(int hor, int ver);rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_Set_Prncomport(int baud, char parity, int data, int stop);rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_Set_Prncomport_PC(int nBaudRate, int nByteSize, int nParity,rn int nStopBits, int nDsr, int nCts, int nXonXoff);rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_Set_Speed(int speed);rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_Set_ProcessDlg(int nShow);rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_GetUSBBufferLen();rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_EnumUSB(byte[] buf);rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_CreateUSBPort(int nPort);rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_ResetPrinter();rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_GetPrinterResponse(byte[] buf, int nMax);rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_TFeedMode(int nMode);rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_TFeedTest();rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_CreatePort(int nPortType, int nPort, string filename);rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_Execute_Form(string form_out, string var);rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_Bar2d_QR(int x, int y, int model, int scl, char error,rn char dinput, int c, int d, int p, string data);rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_GetNetPrinterBufferLen();rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_EnumNetPrinter(byte[] buf);rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_CreateNetPort(int nPort);rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_Prn_Text_TrueType_Uni(int x, int y, int FSize, string FType,rn int Fspin, int FWeight, int FItalic, int FUnline, int FStrikeOut, string id_name,rn byte[] data, int format);rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_Prn_Text_TrueType_UniB(int x, int y, int FSize, string FType,rn int Fspin, int FWeight, int FItalic, int FUnline, int FStrikeOut, string id_name,rn byte[] data, int format);rn [DllImport("Winpplb.<em>dll</em>")]rn private static extern int B_GetUSBDeviceInfo(int nPort, byte[] pDeviceName,rn out int pDeviceNameLen, byte[] pDevicePath, out int pDevicePathLen);rn public <em>dll</em>Operator()rn rnrn rn rnrn public void doPrint(String strText,int count)rn rn int nLen, ret;rn byte[] pbuf = new byte[128];rn string ver, strmsg;rn System.Text.Encoding encAscII = System.Text.Encoding.ASCII;rn System.Text.Encoding encUnicode = System.Text.Encoding.Unicode;rnrn // <em>dll</em> version.rn ver = B_Get_DLL_Version(0);//取得或秀出此函數庫版本資訊。rnrn // search port.rn nLen = B_GetUSBBufferLen() + 1;//查詢 USB 埠資料長度rn strmsg = "DLL ";rn strmsg += ver;rn strmsg += "\r\n";rn if (nLen > 1)rn rn byte[] buf1, buf2;rn int len1 = 128, len2 = 128;rn buf1 = new byte[len1];rn buf2 = new byte[len2];rn B_EnumUSB(pbuf);//取得 USB 埠的資料rn B_GetUSBDeviceInfo(1, buf1, out len1, buf2, out len2);//取得 USB 埠的裝置名稱和裝置路徑。rn ret = B_CreatePrn(12, encAscII.GetString(buf2, 0, len2));// open usb.開啟 Printer 工作。rn if (0 != ret)rn rn strmsg += "Open USB fail!";rn rn elsern rn strmsg += "Open USB:\r\nDevice name: ";rn strmsg += encAscII.GetString(buf1, 0, len1);rn strmsg += "\r\nDevice path: ";rn strmsg += encAscII.GetString(buf2, 0, len2);rn rn rn elsern rn ret = B_CreatePrn(0, szSavePath);// open file.開啟 Printer 工作。rn strmsg += "Open ";rn strmsg += szSavePath;rn if (0 != ret)rn rn strmsg += " file fail!";rn rn elsern rn strmsg += " file succeed!";rn rn rn rn if (0 != ret)rn return;rn // sample setting.rn B_Set_DebugDialog(1);//設定除錯環境。rn B_Set_Originpoint(0, 0);//設定開始列印點。rn B_Select_Option(2);//設定轉印模式、啟動 Cutter 或 Peel。rn B_Set_Darkness(8);//設定熱感頭列印熱度。rn B_Set_Backfeed('F');rn B_Del_Pcx("*");// delete all picture.刪除 Pcx 圖檔。 rn B_Bar2d_QR(420, 200, 1, 3, 'M', 'M', 12, 15, 30, strText);//列印 QR 條碼 "QR CODE"rn B_Print_Out(count);// copy 1.列印所有資料。rn B_ClosePrn();//關閉 Printer 工作。rn rnrn[/code]
尝试读取写入保护内存,这通常指示其他内存已损坏
我用C#做的一个软件,打完包安装后,当单击输出报表的按钮时,出现下面的提示:rn“<em>尝试</em><em>读取</em>或<em>写入</em>受<em>保护</em>的<em>内存</em>,这<em>通常</em><em>指示</em>其他<em>内存</em><em>已损坏</em> ”rn但是,我在开发环境中运行却没有问题,并且有的电脑有这问题,有的电脑没有问题。rn那个提示,是我在操作Excel的一个类中捕获到的,各位大侠帮忙啊!rn那个类的代码如下:rn
尝试读取写入保护内存。这通常指示其他内存已损坏。 ????
<em>尝试</em><em>读取</em>或<em>写入</em>受<em>保护</em>的<em>内存</em>。这<em>通常</em><em>指示</em>其他<em>内存</em><em>已损坏</em>。 rn说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 rnrn异常详细信息: System.AccessViolationException: <em>尝试</em><em>读取</em>或<em>写入</em>受<em>保护</em>的<em>内存</em>。这<em>通常</em><em>指示</em>其他<em>内存</em><em>已损坏</em>。rnrn源错误: rnrnrn行 130: System.Runtime.InteropServices.Marshal.ReleaseComObject(wbs);rn行 131: System.Runtime.InteropServices.Marshal.ReleaseComObject(app);rn行 132: [color=#FF6600]IntPtr t = new IntPtr(app.Hwnd); [/color]rn行 133: int k = 0;rn行 134: GetWindowThreadProcessId(t, out k); rn rnrn源文件: d:\My Documents\Visual Studio 2005\WebSites\meterCheck\App_Code\PublicClass\ReadExcel.cs 行: 132 rnrn堆栈跟踪: rnrnrn[AccessViolationException: <em>尝试</em><em>读取</em>或<em>写入</em>受<em>保护</em>的<em>内存</em>。这<em>通常</em><em>指示</em>其他<em>内存</em><em>已损坏</em>。]rn Excel.ApplicationClass.get_Hwnd() +0rn ReadExcel.GetExcelSheetCount(FileUpload e) in d:\My Documents\Visual Studio 2005\WebSites\meterCheck\App_Code\PublicClass\ReadExcel.cs:132rn Web_upload_firstCheck.ButtonUploadFile_Click(Object sender, EventArgs e) in d:\My Documents\Visual Studio 2005\WebSites\meterCheck\Web\upload\firstCheck.aspx.cs:113rn System.Web.UI.WebControls.Button.OnClick(EventArgs e) +96rn System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +116rn System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +31rn System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +32rn System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +72rn System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3839rnrn怎么回事rnrnrn--------------------------------------------------------------------------------rn版本信息: Microsoft .NET Framework 版本:2.0.50727.832; ASP.NET 版本:2.0.50727.832
vb.net 尝试读取写入保护内存。这通常指示其他内存已损坏
之前报错是:rn“System.AccessViolationException”类型的未经处理的异常在 mscorlib.<em>dll</em> 中发生 rn其他信息: <em>尝试</em><em>读取</em>或<em>写入</em>受<em>保护</em>的<em>内存</em>。这<em>通常</em><em>指示</em>其他<em>内存</em><em>已损坏</em>。rnrn后来我添加了Despose后,出现了如下的错误(直接上图):rn[img=https://img-bbs.csdn.net/upload/201712/13/1513131054_480782.png][/img]rnrn程序时在运行了两三小时之后才出现的,rn请各位大神帮帮忙!
VB2008尝试读取写入保护内存。这通常指示其他内存已损坏
Private Sub PictureBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox1.Clickrn conn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + "\zm.mdb" + "")rn s = "select * from zm1 where id=1"rn rs.Open(s, conn)rn pic = (rs("photo").Value.ToString)rn TabPage1.BackgroundImage = Image.FromFile(pic)rn rs.Close()rn conn.Close()rn End Subrnrn我确定,刚才还好好的...后来都是:rn<em>尝试</em><em>读取</em>或<em>写入</em>受<em>保护</em>的<em>内存</em>。这<em>通常</em><em>指示</em>其他<em>内存</em><em>已损坏</em>。rn排除法发现控件TabPage1.BackgroundImage 有问题.把控件换成picturebox2.image 图片能显示出来.rn.....这样怎么办?? rn使用TabPage1,PictureBox1的背景是透明的,就像桌面一样.rn使用picturebox2,PictureBox1的背景是有白块的,不好看...rn然后,重新做一个工程..tabpage1还是一样不能....rn求解决~~rn[img=https://img-bbs.csdn.net/upload/201409/12/1410502480_645197.jpg][/img]rn[img=https://img-bbs.csdn.net/upload/201409/12/1410502491_961743.jpg][/img]
SaveFileDialog 提示尝试读取写入保护内存。这通常指示其他内存已损坏
[code=csharp]private void ExportExcel()rn rn DataTable dtVilationList = Grab.GetVilationList(guid.ToString());rnrn SaveFileDialog dlg = new SaveFileDialog()rn rn Filter = "*.xls|*.xls",rn RestoreDirectory = true,rn FileName = DateTime.Now.ToString("yyyyMMddhhmmss")rn ;rn if (dlg.ShowDialog() == DialogResult.OK)rn rn string[] columns = new string[] rn "车牌","违规时间","违规行为","违规地点","罚款金额","扣分","异地办理费"rn ;rn int i = 0;rn foreach (string c in columns)rn rn dtVilationList.Columns[i++].ColumnName = c;rn rn CSD.Tools.DownExcel downExcel = new CSD.Tools.DownExcel();rn downExcel.Width(0, 16);rn downExcel.Width(1, 18);rn downExcel.Width(2, 35);rn downExcel.Width(3, 35);rn downExcel.Width(6, 16);rn downExcel.File(dtVilationList, dlg.FileName);rn MessageBox.Show("导出成功!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);rn rn [/code]rn第一次SaveFileDialog 是正常显示,并能保存,,再次点击导出Excel的话会报错误,rn错误定位在,“ if (dlg.ShowDialog() == DialogResult.OK)”rn错误信息:<em>尝试</em><em>读取</em>或<em>写入</em>受<em>保护</em>的<em>内存</em>。这<em>通常</em><em>指示</em>其他<em>内存</em><em>已损坏</em>。rn数据是从Access<em>读取</em>的
VC++串口通信20个经典源码合集下载
VC++串口通信20个经典源码合集\VC 串口通信程序.rar ............................\VC 读串口话是动态波形,非常好的应用程序,有源码.rar ............................\VC++ 串口实现双机互联 包含视窗加代码.rar ............................\VC++ 串口通信,可以收发数据,可选用TCPIP 通信.rar ............................\vc++ 开放的串口通讯程序,经测试特别好用.rar .......................... 相关下载链接:[url=//download.csdn.net/download/wwwpengdong/5025197?utm_source=bbsseo]//download.csdn.net/download/wwwpengdong/5025197?utm_source=bbsseo[/url]
支持IE6 IE7 Firefox的纯CSS的下拉菜单下载
支持IE6 IE7 Firefox的纯CSS的下拉菜单! 值得下载看看!资源免费,大家分享!! 更多免费资源 http://ynsky.download.csdn.net/ 相关下载链接:[url=//download.csdn.net/download/ynsky/2405746?utm_source=bbsseo]//download.csdn.net/download/ynsky/2405746?utm_source=bbsseo[/url]
ext-----中文字体处理下载
ext中文字体处理--------------------------------------- 相关下载链接:[url=//download.csdn.net/download/wen691/2913102?utm_source=bbsseo]//download.csdn.net/download/wen691/2913102?utm_source=bbsseo[/url]
文章热词 机器学习教程 Objective-C培训 交互设计视频教程 颜色模型 设计制作学习
相关热词 mysql关联查询两次本表 native底部 react extjs glyph 图标 云计算价格内存 java 内存学习
我们是很有底线的