请兄弟们帮我分析下代码,经常会崩溃,郁闷啊

ccj188 2009-12-12 11:15:54
代码可能有些长,请各位兄弟耐住性子看看,感激不尽:


using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using System.Configuration;
using System.Runtime.InteropServices;

namespace 滁州移动服务评价系统
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

//引用dll部分
#region
Cls cls = new Cls();
[DllImport("centerm_i70.dll", EntryPoint = "GetPasswordFromKeypad", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int GetPasswordFromKeypad(ref Cls.COMMPARAMETER stComParam, ref string strPassword, int nLen, int nMode, double nTimeout);
[DllImport("centerm_i70.dll", EntryPoint = "SetEvaluatorInfo", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SetEvaluatorInfo(ref Cls.COMMPARAMETER stComParam, string strDepartment, string strPosition, string strID, int nStar);
[DllImport("centerm_i70.dll", EntryPoint = "GetEvaluationFromEvaluator", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int GetEvaluationFromEvaluator(ref Cls.COMMPARAMETER stComParam, ref string strEvaluation, int nEvaLen, ref string strReason, int nReaLen, int nTimeout);
[DllImport("centerm_i70.dll", EntryPoint = "GetValueFromInfoviewer", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int GetValueFromInfoviewer(ref Cls.COMMPARAMETER stComParam, ref string strValue, int nVLen, int nTimeout);
[DllImport("centerm_i70.dll", EntryPoint = "AppendToInfoviewer", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int AppendToInfoviewer(ref Cls.COMMPARAMETER stComParam, string strInfo, int nLen);
[DllImport("centerm_i70.dll", EntryPoint = "ClearInfoviewer", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int ClearInfoviewer(ref Cls.COMMPARAMETER stComParam);
[DllImport("centerm_i70.dll", EntryPoint = "EnableInfoviewer", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int EnableInfoviewer(ref Cls.COMMPARAMETER stComParam);
[DllImport("centerm_i70.dll", EntryPoint = "SetInfoviewerText", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SetInfoviewerText(ref Cls.COMMPARAMETER stComParam, int fontsize, string fontcolor, string backcolor);
[DllImport("centerm_i70.dll", EntryPoint = "ListPictureBegin", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int ListPictureBegin(ref Cls.COMMPARAMETER stComParam, ref string listBuffer, ref int nSize, int nTimeout);
[DllImport("centerm_i70.dll", EntryPoint = "ListPictureEnd", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int ListPictureEnd(string listBuffer);
[DllImport("centerm_i70.dll", EntryPoint = "ListMP3AudioBegin", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int ListMP3AudioBegin(ref Cls.COMMPARAMETER stComParam, ref string listBuffer, ref int nSize, int nTimeout);
[DllImport("centerm_i70.dll", EntryPoint = "ListMP3AudioEnd", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int ListMP3AudioEnd(string listBuffer);
[DllImport("centerm_i70.dll", EntryPoint = "DownloadOperatorPicture", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int DownloadOperatorPicture(ref Cls.COMMPARAMETER stComParam, string strSrcFileName, string strDestFileName, int outtime);
[DllImport("centerm_i70.dll", EntryPoint = "PlayMP3Audio", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int PlayMP3Audio(ref Cls.COMMPARAMETER stComParam, string strFileName);
[DllImport(".\\centerm_i70.dll", EntryPoint = "isCommPortUsed", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int isCommPortUsed(); //检测端口是否被占用
[DllImport(".\\centerm_i70.dll", EntryPoint = "ForceCloseCommPort", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int ForceCloseCommPort(ref Cls.COMMPARAMETER stComParam);//关闭当前端口
[DllImport(".\\centerm_i70.dll", EntryPoint = "CloseApplication", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int CloseApplication(ref Cls.COMMPARAMETER stComParam); //关闭程序
#endregion

//程序初始化
public DataSet ds = null;
public static string _tc = "";
public static string _pj = "";
public static string _pwd = "";
public static int ppstate = 0;
public static string loadhtml = "";
public static string loadurl = "";
private void Form1_Load(object sender, EventArgs e)
{
CSHLoad csh = new CSHLoad();
csh.label1.Text = "系统正在初始化中,请稍后...";
csh.ShowDialog();
string _text = ConfigurationSettings.AppSettings["title"].ToString();
string _pwdname = ConfigurationSettings.AppSettings["pwdname"].ToString();
string _telname = ConfigurationSettings.AppSettings["telname"].ToString();
string _submitname = ConfigurationSettings.AppSettings["submitname"].ToString();
string _frmname = ConfigurationSettings.AppSettings["frmname"].ToString();
Cls.bossurl = ConfigurationSettings.AppSettings["bossurl"].ToString();
_tc = ConfigurationSettings.AppSettings["tc"].ToString();
_pj = ConfigurationSettings.AppSettings["pj"].ToString();
_pwd = ConfigurationSettings.AppSettings["pwd"].ToString();

this.Text = "滁州移动综合业务系统(版本:" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + ")";// _text;
if (_pwdname != "" && _submitname != "")
{
Cls.submitname = _submitname;
Cls.pwdname = _pwdname;
Cls.telname = _telname;
Cls.frmname = _frmname;
}
else
{ MessageBox.Show("程序初始化失败,请设置app.config文件"); }
toolStripLabel1.Text = Cls.usercode;
}

//检验加载是否完毕
private void webBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e)
{
timer1.Start();
}
...全文
208 25 打赏 收藏 转发到动态 举报
写回复
用AI写文章
25 条回复
切换为时间正序
请发表友善的回复…
发表回复
huminghuazhang 2010-03-01
  • 打赏
  • 举报
回复
引用 18 楼 fellatioyzx 的回复:
大哥你至少调试一下,告诉我们错误大概在哪里。。。


顶你说的
呵呵 我是新手 只是看看
wzp144650 2009-12-15
  • 打赏
  • 举报
回复
你的那些DLL没问题嘛
zj1494822 2009-12-14
  • 打赏
  • 举报
回复
天啊,大哥,太长了吧!

帮顶了!!
ccj188 2009-12-14
  • 打赏
  • 举报
回复
[Quote=引用 18 楼 fellatioyzx 的回复:]
大哥你至少调试一下,告诉我们错误大概在哪里。。。
[/Quote]

大哥,我都调试过了,没有任何错误,但是在客户服务器上经常会崩溃,就是找不到错误,才请大家帮我分析下。找到错误了,我就不贴这么长的代码,杀各位兄弟的脑细胞了,呵呵
cjnkd 2009-12-14
  • 打赏
  • 举报
回复
顶,最好发源文件,在运行过程中,看一看还行,直接发代码,除非很明显的错误,不然很难看出来的。
孤剑 2009-12-13
  • 打赏
  • 举报
回复
代码没有排版,很难检查,建议如下操作:
1、服务器端捕捉异常,加 try...catch... finally 或用 windbg 跟进检查;
2、查看服务器系统日志,看是否能有其他收获。

ps: ApplicationSettings 最好加上 try...catch ,原因: web.config 或 App.config 中可能泄漏节点
m555888 2009-12-13
  • 打赏
  • 举报
回复
我再顶!
ccj188 2009-12-13
  • 打赏
  • 举报
回复
[Quote=引用 17 楼 hellowordc 的回复:]
有谁会为了回答一个问题,去努力看懂这长的代码?那真的是要佩服他的热情、耐心和水平了。

我觉得我们在这里提问题,应该自己要反复推敲一下自己的问题,把自己的问题浓缩成一个模型,这样得到满意答案的几率会大大提高。这样不管三七二十一把自己出问题的代码拷贝上来一大片,肯定是解决不了问题的。

友情提示一下而已!


【原创家庭记账簿1.2,简单实用,欢迎工薪阶层、家庭主妇下载使用
http://download.csdn.net/source/1894835】

[/Quote]

你说的很有道理,我也这样提过问题,得到的答案就是仔细检查你的代码,可定哪有有问题,或让我加上try cacth ,很多还说没有代码无法帮分析,我也知道这么长的代码很难看,没有办法啊。
提供个代码,只供分析用,谢谢楼上的兄弟热情提示。
ccj188 2009-12-13
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 wuyq11 的回复:]
看看系统日志
数据库操作使用数据库操作类,资源及时释放
[/Quote]

数据的使用后都及时的释放了。
fellatioyzx 2009-12-13
  • 打赏
  • 举报
回复
大哥你至少调试一下,告诉我们错误大概在哪里。。。
HELLOWORDC 2009-12-13
  • 打赏
  • 举报
回复
有谁会为了回答一个问题,去努力看懂这长的代码?那真的是要佩服他的热情、耐心和水平了。

我觉得我们在这里提问题,应该自己要反复推敲一下自己的问题,把自己的问题浓缩成一个模型,这样得到满意答案的几率会大大提高。这样不管三七二十一把自己出问题的代码拷贝上来一大片,肯定是解决不了问题的。

友情提示一下而已!


【原创家庭记账簿1.2,简单实用,欢迎工薪阶层、家庭主妇下载使用
http://download.csdn.net/source/1894835】
悔说话的哑巴 2009-12-13
  • 打赏
  • 举报
回复
实在是太长了
zhh2008p 2009-12-13
  • 打赏
  • 举报
回复
额。。太长了。。
m555888 2009-12-12
  • 打赏
  • 举报
回复
再换个 远程pc 访问一下 试试!!!!
wuyq11 2009-12-12
  • 打赏
  • 举报
回复
看看系统日志
数据库操作使用数据库操作类,资源及时释放
红街咖啡 2009-12-12
  • 打赏
  • 举报
回复
是秀代码吗?
红街咖啡 2009-12-12
  • 打赏
  • 举报
回复
这个...
xiongxyt2 2009-12-12
  • 打赏
  • 举报
回复
是啊,看花眼了
ccj188 2009-12-12
  • 打赏
  • 举报
回复
其中一些cls中使用的代码只是一些兑取数据库和字符出来的东东,对代码没有什么影响,大家看看几个线程的使用上有没有什么问题,这个代码安装在2003服务器上,然后很一些人在远程通过终端(相当一个pc)登陆2003的用户,并同时使用这个程序,我在我开发的台式机和笨笨上都没有任何的问题,就是在那个服务器上有问题。经常会崩溃。
  • 打赏
  • 举报
回复
我看也崩溃了,一时半会都看不完
加载更多回复(4)

111,120

社区成员

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

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

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