这是一个p2p的客户端程序,因此要装在多台机器上做实验,不可能每台机器都装visual studio 2003重新编译的。在编译的机器上,直接运行release目录下的exe文件也能正常运行。报错给出的进程号和线程号每次运行都不同,所以就没有列出来。并且在调试的过程中发现,在application.run()之前没错,run之后就报错,还没有进入构造函数。下面给出类的声明和构造函数的代码,请大家帮忙看看。完整的代码太长,就不全部贴出了。 namespace Listener { // Library includes using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Net; // added for httprequest and responses and hostname resolving using System.IO; // added for file streaming using System.Text; // added for text encodings using WorkingWithXML; using System.Net.Sockets; using System.Threading; using System.Runtime.InteropServices; using System.Windows.Forms.Design; public delegate void StreamingCallBackDeligates(string e,StreamIt str); public class frmLogin : System.Windows.Forms.Form { ThreadIndex threadIndex; private System.Windows.Forms.Label label1; private System.Windows.Forms.TextBox textPassWord; private DevExpress.XtraEditors.SimpleButton btnLogin; private DevExpress.XtraEditors.TextEdit textLoginID; private System.Windows.Forms.MenuItem menuItem2; Socket newSock; [DllImport("Shell32.dll")] public static extern int ShellExecute(int hwnd, string lpVerb, string lpFile, string lpParameters, string lpDirectory, int nShowCmd ); // State maintainig variables; private bool bLoggedIn; private int IconNo; private int ThreadCount; private bool bShareDialogOpend; private bool bDownLoading; private bool bStreaming; private int connectedStreamingClients; private int intStreamingThreadIndex; private Form1 form ; private Byte[] buffer; private string LoginName; private int ChatWindowCount; // Variable required in communication with server private ServerCommunication xmlServerComm; //Communcation facilitators on sockets. //private TCPListener servSock; private Socket servSock; // private Socket newSock; // Xml reuests and responses are created using these objects private XMLCreater xmlCreater; private XMLParser xmlParser; // Threads of this application's being. // Threads for continious update on sys tray // and for continious seeking for connections // from browsers, respactively. private Thread AcceptThread,ThreadIcon,RespondingThread; private System.ComponentModel.IContainer components; private System.Windows.Forms.ToolTip toolTip1; private System.Windows.Forms.MenuItem ctxMenuShare; private System.Windows.Forms.MenuItem ctxMenuQuit; private System.Windows.Forms.Button btnShareFileFolder; private System.Windows.Forms.Label labelLoginID; private System.Windows.Forms.CheckBox chkRemeberID; private System.Windows.Forms.Button btnQuit; private System.Windows.Forms.MenuItem menuItem1; private System.Windows.Forms.MenuItem ListenCntxtMenu; private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.NotifyIcon ListenIcon; private System.Windows.Forms.ContextMenu contextMenu; private System.Windows.Forms.Button button1; // First functions that gets called in this form's life cycle // Initailizes all the GUI controls and reads username last //used, if any and puts that on the form. public frmLogin() { InitializeComponent();
// initialise objects getting used while communication // and parsing xmlServerComm = new WorkingWithXML.ServerCommunication(); xmlParser = new WorkingWithXML.XMLParser(); xmlParser.LOGINXML = Application.StartupPath + "\\Login.xml"; textLoginID.Text = ReadUsername(); bLoggedIn = false; bShareDialogOpend = false; bDownLoading = false; IconNo = 1; ChatWindowCount = 0; LoginName = ""; AcceptThread = null; ThreadIcon = null; RespondingThread = null; threadIndex = new ThreadIndex(); ThreadCount = 0; bStreaming = false; form = null; intStreamingThreadIndex = 0; connectedStreamingClients = 0; }main函数为: [STAThread] public static void Main(string[] args) { Application.Run(new frmLogin()); }
还有就是目标机器的iis是否能够正常运行;
以及程序中是否使用了directory类的相关函数进行目录操作等等!
尝试之前不妨试一试stdotleo(大雨仔) ( ) 的方法,在目标机器上重新编译一变,会有相关信息提示的!!
namespace Listener
{
// Library includes
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Net; // added for httprequest and responses and hostname resolving
using System.IO; // added for file streaming
using System.Text; // added for text encodings
using WorkingWithXML;
using System.Net.Sockets;
using System.Threading;
using System.Runtime.InteropServices;
using System.Windows.Forms.Design; public delegate void StreamingCallBackDeligates(string e,StreamIt str); public class frmLogin : System.Windows.Forms.Form
{
ThreadIndex threadIndex;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox textPassWord;
private DevExpress.XtraEditors.SimpleButton btnLogin;
private DevExpress.XtraEditors.TextEdit textLoginID;
private System.Windows.Forms.MenuItem menuItem2;
Socket newSock;
[DllImport("Shell32.dll")]
public static extern int ShellExecute(int hwnd,
string lpVerb,
string lpFile,
string lpParameters,
string lpDirectory,
int nShowCmd ); // State maintainig variables;
private bool bLoggedIn;
private int IconNo;
private int ThreadCount;
private bool bShareDialogOpend;
private bool bDownLoading;
private bool bStreaming;
private int connectedStreamingClients;
private int intStreamingThreadIndex;
private Form1 form ; private Byte[] buffer;
private string LoginName;
private int ChatWindowCount;
// Variable required in communication with server
private ServerCommunication xmlServerComm; //Communcation facilitators on sockets.
//private TCPListener servSock;
private Socket servSock;
// private Socket newSock; // Xml reuests and responses are created using these objects
private XMLCreater xmlCreater;
private XMLParser xmlParser;
// Threads of this application's being.
// Threads for continious update on sys tray
// and for continious seeking for connections
// from browsers, respactively.
private Thread AcceptThread,ThreadIcon,RespondingThread; private System.ComponentModel.IContainer components;
private System.Windows.Forms.ToolTip toolTip1;
private System.Windows.Forms.MenuItem ctxMenuShare;
private System.Windows.Forms.MenuItem ctxMenuQuit;
private System.Windows.Forms.Button btnShareFileFolder;
private System.Windows.Forms.Label labelLoginID;
private System.Windows.Forms.CheckBox chkRemeberID;
private System.Windows.Forms.Button btnQuit;
private System.Windows.Forms.MenuItem menuItem1;
private System.Windows.Forms.MenuItem ListenCntxtMenu;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.NotifyIcon ListenIcon;
private System.Windows.Forms.ContextMenu contextMenu;
private System.Windows.Forms.Button button1; // First functions that gets called in this form's life cycle
// Initailizes all the GUI controls and reads username last
//used, if any and puts that on the form.
public frmLogin()
{
InitializeComponent();
// initialise objects getting used while communication
// and parsing
xmlServerComm = new WorkingWithXML.ServerCommunication();
xmlParser = new WorkingWithXML.XMLParser();
xmlParser.LOGINXML = Application.StartupPath + "\\Login.xml";
textLoginID.Text = ReadUsername();
bLoggedIn = false;
bShareDialogOpend = false;
bDownLoading = false;
IconNo = 1;
ChatWindowCount = 0;
LoginName = "";
AcceptThread = null;
ThreadIcon = null;
RespondingThread = null;
threadIndex = new ThreadIndex();
ThreadCount = 0;
bStreaming = false;
form = null;
intStreamingThreadIndex = 0;
connectedStreamingClients = 0;
}main函数为:
[STAThread]
public static void Main(string[] args)
{
Application.Run(new frmLogin());
}