Application has generated an exception that coult not be handled

冷小莫88 2010-05-28 06:26:25
Application has generated an exception that coult not be handled
小弟我遇到一个问题,请各位大虾,帮忙看看,我是做医保读卡器的接口,在我电脑上可以执行,但是到客户机子上就出先这个错误,具体的是,调试到我调用的动态库函数那出错,但是在我电脑上为什么不出错呢。请各位大虾指点下!
...全文
302 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
冷小莫88 2010-08-17
  • 打赏
  • 举报
回复
谢谢,问题已解决,谢谢大家帮主!!
APP开发王 2010-06-09
  • 打赏
  • 举报
回复

友情帮顶下!顺便学习学习!
缭绕飘渺 2010-06-01
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 wuyq11 的回复:]
检查是否缺少相关文件
日志记录
catch看看错误
AppDomain currentDomain = AppDomain.CurrentDomain;
currentDomain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledExceptions);
private void Unhandle……
[/Quote]
用这个处理未处理的异常,然后记录下异常的信息
first_wang2000 2010-05-30
  • 打赏
  • 举报
回复
学习中,谢谢
冷小莫88 2010-05-28
  • 打赏
  • 举报
回复
ly302大虾,你好像我和做的一样,小弟刚入行,请多多指点下
冷小莫88 2010-05-28
  • 打赏
  • 举报
回复
我已经打SP1补丁了。还是不行,就到到我调用动态函数那出错,是不是我的调的函数有误啊,小弟刚做,经验少,谢谢各位大虾的指点,我把源码贴上大家,帮忙看下
[System.Runtime.InteropServices.DllImport("Comm.dll",EntryPoint="ReadCardNo")] //申明API函数
public static extern int ReadCardNo(out string sCardNo,out string sPsamInfo,int nComPort);

/// <summary>
/// 发送读卡请求
/// </summary>
/// <returns></returns>
public static int SendReadCard()
{
int result=205;
int ComPort=ReadComPort();
string CardNo=new string(' ',21);
string PsamInfo=new string(' ',9);
result =ReadCard.ReadCardNo(out CardNo,out PsamInfo,ComPort);
if(result==0)
{
CardNum=CardNo;
CardInfo=PsamInfo;
return result;
}
else
{
return result;
}
}


public static int ReadComPort()
{
int result=0;
string servicePath = System.Configuration.ConfigurationSettings.AppSettings["ComPort"].ToString();
result=int.Parse(servicePath);
return result;
}
下面这个是读取PC机端口的配置,我配置成2,3,4,没事,配置成1就出那个错

十三. IC卡动态链接库(comm.dll)函数说明:
函数:读取卡号
int ReadCardNo(char * sCardNo,char * sPsamInfo,int nComPort)
参数 sCardNo 返回卡号(20位,如不足,后面为空格)
sPsamInfo 返回PSAM卡信息(8位)
nComPort 端口号
返回值 参考说明中的返回值
说明:
1) 为了兼容新老卡,所以该说明只提供读卡号的函数。
2) 在接口函数中对于字符串类型的返回参数(如sCardInfo),必须事先分配空格字符串,再进行调用,以免出现非法操作。譬如:sCardNo分配21个字节,sPsamInfo分配9个字节。
3) sPsamInfo返回参数是PSAM卡信息,PSAM卡是为了验证IC卡的合法性,每个读卡器对应一张PSAM卡。要求HIS开发商上传sPsamInfo信息。
4) nComPort参数指的是读卡器串口号,PC机器上端口号一般是1或2,笔记本电脑上端口号一般是1或2或3或4。要求HIS开发商在配置文件中读取端口号,再传入函数中。
5) 返回值
wuyq11 2010-05-28
  • 打赏
  • 举报
回复
检查是否缺少相关文件
日志记录
catch看看错误
AppDomain currentDomain = AppDomain.CurrentDomain;
currentDomain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledExceptions);
private void UnhandledExceptions(object sender, UnhandledExceptionEventArgs args)
{ }
皇城龙三 2010-05-28
  • 打赏
  • 举报
回复
你是用.net开发的么?

医保读卡器接口,我用PB开发没有任何问题

.net sp1的补丁没有打得话,也会出现这个问题

你用Release生成一个版本看看,先不要用debug的
guyehanxinlei 2010-05-28
  • 打赏
  • 举报
回复
检查一下是否缺少必要的资源

再检查一下读卡器的帮助文档

17,740

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 .NET Framework
社区管理员
  • .NET Framework社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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