BillingSoftware.exe [2008]中发生了无法使用的Microsoft .Net Framework异常 [英] An Unhanded Microsoft .Net Framework exception occurred in BillingSoftware.exe[2008]

查看:69
本文介绍了BillingSoftware.exe [2008]中发生了无法使用的Microsoft .Net Framework异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生我制作一个Windows应用程序试用配对

问题是:当我构建一个安装文件并在我的系统上运行然后它成功运行当我提供客户端使用这个项目它给出错误运行,打开一个对话框,消息是



关闭程序..并检查调试模式..当我在调试模式下检查然后找到错误。





BillingSoftware.exe [2008]中发生了无法使用的Microsoft .Net Framework异常



运行2010 Framework我发现错误

C:/programFile/System32/PRSetp.dbf访问被拒绝...









...先生它制作PRSetp.dbf文件(不在客户端计算机中制作)它将在My中成功运行系统但是Clint系统出错了c:/programFile/System32/PRSetp.dbf访问被拒绝

如何在客户端机器上制作PRsetp.dbf文件请帮帮我.........



我的代码显示:



Application.EnableVisualStyles();

申请。 SetCompatibleTextRenderingDefault(false);

string registery = AppDomain.CurrentDomain.BaseDirectory; // Application.StartupPath;

registery = registery.Replace(\\bin\ \ Debug,);

registery = re gistery +PRegFile.reg;

string s = Environment.GetFolderPath(Environment.SpecialFolder.System);

TrialMaker t = new TrialMaker(Application.ProductName,Application。 StartupPath +\\PRegFile.reg,

s +\\PRSetp.dbf,

联系电话:,

2,10,745);





/ *叫承包商* /



public TrialMaker(string SoftwareName,

string RegFilePath,string HideFilePath,

string Text,int TrialDays,int TrialRunTimes,

string Identifier)

{

_SoftName = SoftwareName;

_Identifier = Identifier;



SetDefaults();



_DefDays = TrialDays;

_Runed = TrialRunTimes;



_RegFilePath = RegFilePath;

_HideFilePath = HideFilePath;

_Text =文字;

}



private void SetDefaults()

{SystemInfo.UseBaseBoardManufacturer = SystemInfo.UseBiosManufacturer = SystemInfo.UsePhysicalMediaSerialNumber = SystemInfo.UseVideoControllerCaption = SystemInfo.UseWindowsSerialNumber = false;

SystemInfo.UseBaseBoardProduct =真;

SystemInfo.UseBiosVersion = true;

SystemInfo.UseDiskDriveSignature = true;

SystemInfo.UseProcessorID = true;



MakeBaseString();

MakePassword();

}

//制作基本字符串(计算机ID)

private void MakeBaseString()

{

_BaseString = Encryption.Boring(Encryption.InverseByBase(SystemInfo.GetSystemInfo(_SoftName),10));

}



private void MakePassword()

{

_Password = Encryption.MakePassword(_BaseString,_Identifier);

}



///< summary>

///向用户显示注册对话框

///

// /< returns>运行类型

public RunTypes ShowDialog()

{

//检查是否在
$ b之前注册$ b if(CheckRegister()== true)

返回RunTypes.Trial;



frmDialogBox PassDialog = new frmDialogBox(_BaseString,_Password,DaysToEnd(),_ Runed,_Text);



MakeHideFile();



DialogResult DR = PassDialog.ShowDialog();



if(DR == System.Windows.Forms.DialogResult.OK)

{

MakeRegFile();

返回RunTypes.Full;

}

else if(DR == DialogResult.Retry)

返回RunTypes.Trial;

else

返回RunTypes.Expired;

}



//将密码保存到注册文件以供下次使用

private void MakeRegFile()

{

FileReadWrite.WriteFile(_RegFilePath,_Password);

}



//控制密码保存文件

//如果密码保存正确则返回true否则返回false

private bool CheckRegister()

{

string Password = FileReadWrite.ReadFile(_RegFilePath);



if(_Password == Password)

返回true;

else

返回false;

}



//来自隐藏文件

//表示用户可以使用多少天程序

//如果文件不存在,请将其设为

private int DaysToEnd()

{

FileInfo hf = new FileInfo(_HideFilePath);

if(hf.Exists == false)

{

MakeHideFile();

返回_DefDays;

}

返回车ckHideFile();

}



//将隐藏信息存储到隐藏文件

// Date,DaysToEnd ,HowManyTimesRuned,BaseString(ComputerID)

private void MakeHideFile()

{

string HideInfo;

HideInfo = DateTime.Now.Ticks +;;

HideInfo + = _DefDays +; + _Runed +; + _BaseString;

FileReadWrite.WriteFile(_HideFilePath,HideInfo);



}



//从隐藏文件中获取数据(如果存在)

private int CheckHideFile()

{

string [] HideInfo;

HideInfo = FileReadWrite.ReadFile(_HideFilePath).Split(';');

long DiffDays;

int DaysToEnd;



if(_BaseString == HideInfo [3])

{

DaysToEnd = Convert.ToInt32(HideInfo [1]);

if(DaysToEnd< = 0)

{

_Runed = 0;

_DefDays = 0;

返回0;

}

DateTime dt = new DateTime(Convert.ToInt64(HideInfo [0]));

DiffDays = Dat eAndTime.DateDiff(DateInterval.Day,

dt.Date,DateTime.Now.Date,

FirstDayOfWeek.Saturday,

FirstWeekOfYeY.FirstFullWeek) ;





DaysToEnd = Convert.ToInt32(HideInfo [1]);

_Runed = Convert.ToInt32 (HideInfo [2]);

_Runed - = 1;



DiffDays = Math.Abs​​(DiffDays);



_DefDays = DaysToEnd - Convert.ToInt32(DiffDays);

}

返回_DefDays;

}



public enum RunTypes

{

Trial = 0,

Full ,

已过期,

未知

}



///<摘要>

///表示文件p用于存储密码

///

公共字符串RegFilePath

{

get

{

返回_RegFilePath;

}

设定

{

_RegFilePath =值;

}

}



///< summary>

///表示存储隐藏信息的文件路径

///

公共字符串HideFilePath

{

get

{

return _HideFilePath;

}

set

{

_HideFilePath = value;

}

}



///<摘要>

///获取试用期的默认天数

///

public int TrialPeriodDays

{

get

{

返回_DefDays;

}

}



///< summary>

///获取或设置TripleDES密钥以加密要保存的文件

///

public byte [] TripleDESKey

{

get

{

返回FileReadWrite.key;

}

set

{

FileReadWrite.key = value;

}

}

< br $>








}

sir i m Make a windows application For Trial Paired
Problem is: when i build A setup file and Run on My System Then it Run Successfully and when i provide client for use this project it gives error to run,open a dialog box and Message is

closed program .. and check debug mode .. while i m checking in debug mode then find error .

and
An Unhanded Microsoft .Net Framework exception occurred in BillingSoftware.exe[2008]

Run on 2010 Framework i find error
C:/programFile/System32/PRSetp.dbf Access Denied ...




... sir it Make PRSetp.dbf file (does Not make in Client Computer ) it will Run successfully in My System But Clint System Getting Error c:/programFile/System32/PRSetp.dbf Access Denied
how to make PRsetp.dbf file in Client machine please help me .........

my code shown:

Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
string registery = AppDomain.CurrentDomain.BaseDirectory;// Application.StartupPath;
registery=registery.Replace("\\bin\\Debug", "");
registery = registery + "PRegFile.reg";
string s = Environment.GetFolderPath(Environment.SpecialFolder.System);
TrialMaker t = new TrialMaker(Application.ProductName, Application.StartupPath + "\\PRegFile.reg",
s+ "\\PRSetp.dbf",
"Contact numbers: ",
2, 10, "745");


/* Called Contractor*/

public TrialMaker(string SoftwareName,
string RegFilePath, string HideFilePath,
string Text, int TrialDays, int TrialRunTimes,
string Identifier)
{
_SoftName = SoftwareName;
_Identifier = Identifier;

SetDefaults();

_DefDays = TrialDays;
_Runed = TrialRunTimes;

_RegFilePath = RegFilePath;
_HideFilePath = HideFilePath;
_Text = Text;
}

private void SetDefaults()
{ SystemInfo.UseBaseBoardManufacturer = SystemInfo.UseBiosManufacturer =SystemInfo.UsePhysicalMediaSerialNumber = SystemInfo.UseVideoControllerCaption = SystemInfo.UseWindowsSerialNumber =false;
SystemInfo.UseBaseBoardProduct = true;
SystemInfo.UseBiosVersion = true;
SystemInfo.UseDiskDriveSignature = true;
SystemInfo.UseProcessorID = true;

MakeBaseString();
MakePassword();
}
// Make base string (Computer ID)
private void MakeBaseString()
{
_BaseString = Encryption.Boring(Encryption.InverseByBase(SystemInfo.GetSystemInfo(_SoftName), 10));
}

private void MakePassword()
{
_Password = Encryption.MakePassword(_BaseString, _Identifier);
}

/// <summary>
/// Show registering dialog to user
///
/// <returns>Type of running
public RunTypes ShowDialog()
{
// check if registered before
if (CheckRegister() == true)
return RunTypes.Trial;

frmDialogBox PassDialog = new frmDialogBox(_BaseString, _Password, DaysToEnd(), _Runed, _Text);

MakeHideFile();

DialogResult DR = PassDialog.ShowDialog();

if (DR == System.Windows.Forms.DialogResult.OK)
{
MakeRegFile();
return RunTypes.Full;
}
else if (DR == DialogResult.Retry)
return RunTypes.Trial;
else
return RunTypes.Expired;
}

// save password to Registration file for next time usage
private void MakeRegFile()
{
FileReadWrite.WriteFile(_RegFilePath, _Password);
}

// Control Registeration file for password
// if password saved correctly return true else false
private bool CheckRegister()
{
string Password = FileReadWrite.ReadFile(_RegFilePath);

if (_Password == Password)
return true;
else
return false;
}

// from hidden file
// indicate how many days can user use program
// if the file does not exists, make it
private int DaysToEnd()
{
FileInfo hf = new FileInfo(_HideFilePath);
if (hf.Exists == false)
{
MakeHideFile();
return _DefDays;
}
return CheckHideFile();
}

// store hidden information to hidden file
// Date,DaysToEnd,HowManyTimesRuned,BaseString(ComputerID)
private void MakeHideFile()
{
string HideInfo;
HideInfo = DateTime.Now.Ticks + ";";
HideInfo += _DefDays + ";" + _Runed + ";" + _BaseString;
FileReadWrite.WriteFile(_HideFilePath, HideInfo);

}

// Get Data from hidden file if exists
private int CheckHideFile()
{
string[] HideInfo;
HideInfo = FileReadWrite.ReadFile(_HideFilePath).Split(';');
long DiffDays;
int DaysToEnd;

if (_BaseString == HideInfo[3])
{
DaysToEnd = Convert.ToInt32(HideInfo[1]);
if (DaysToEnd <= 0)
{
_Runed = 0;
_DefDays = 0;
return 0;
}
DateTime dt = new DateTime(Convert.ToInt64(HideInfo[0]));
DiffDays = DateAndTime.DateDiff(DateInterval.Day,
dt.Date, DateTime.Now.Date,
FirstDayOfWeek.Saturday,
FirstWeekOfYear.FirstFullWeek);


DaysToEnd = Convert.ToInt32(HideInfo[1]);
_Runed = Convert.ToInt32(HideInfo[2]);
_Runed -= 1;

DiffDays = Math.Abs(DiffDays);

_DefDays = DaysToEnd - Convert.ToInt32(DiffDays);
}
return _DefDays;
}

public enum RunTypes
{
Trial = 0,
Full,
Expired,
UnKnown
}

/// <summary>
/// Indicate File path for storing password
///
public string RegFilePath
{
get
{
return _RegFilePath;
}
set
{
_RegFilePath = value;
}
}

/// <summary>
/// Indicate file path for storing hidden information
///
public string HideFilePath
{
get
{
return _HideFilePath;
}
set
{
_HideFilePath = value;
}
}

/// <summary>
/// Get default number of days for trial period
///
public int TrialPeriodDays
{
get
{
return _DefDays;
}
}

/// <summary>
/// Get or Set TripleDES key for encrypting files to save
///
public byte[] TripleDESKey
{
get
{
return FileReadWrite.key;
}
set
{
FileReadWrite.key = value;
}
}





}

推荐答案

不要试图将您的文件保存在任何System文件夹下,甚至不要放在Program Files文件夹下 - 它可以在开发中使用,因为teh fi le在你的Project / Bin / Debug文件夹中创建,没有访问限制 - 发布的代码不使用该结构,并且严格限制访问teh Program Files文件夹以减少病毒和木马活动 - 这些限制只会得到stringer,不要打火机。



见这里:我应该在哪里存储我的数据? [ ^ ]它会建议更好的地方并告诉你如何使用它们。
Do not try to keep your files under any System folder, or even under the Program Files folder - it works in development because teh file is created in your Project/Bin/Debug folder which has no access restrictions - released code does not use that structure, and access to teh Program Files folder is severely restricted to reduce virus and trojan activity - and these restrictions will only get stringer, not lighter.

See here: Where should I store my data?[^] it suggests better places and shows you how to use them.


这篇关于BillingSoftware.exe [2008]中发生了无法使用的Microsoft .Net Framework异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆