我用vs2008自带的打包工具打包一个项目,想在安装时,做一个验证序列号的操作,我在自定义用户界面中添加了一个这样的界面,用来接收用户输入的序列号,
写了安装程序类,如下
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
using System.Linq;
using System.Windows.Forms;
using BLL;
namespace Install
{
[RunInstaller(true)]
public partial class MyInstaller : Installer
{
public MyInstaller()
{
InitializeComponent();
}
protected override void OnAfterInstall(IDictionary savedState)
{
base.OnAfterInstall(savedState);
}
public override void Install(IDictionary stateSaver)
{
base.Install(stateSaver);
BLL.SerialBLL bll = new SerialBLL();
string message = Context.Parameters["message"].ToString();
MessageBox.Show(message);
if (bll.CheckSerail(message) == true)
{
MessageBox.Show("激活成功"); }
else
{
MessageBox.Show("激活失败");
return;
}
}
protected override void OnBeforeInstall(IDictionary savedState)
{ base.OnBeforeInstall(savedState); }
public override void Uninstall(IDictionary savedState)
{
base.Uninstall(savedState); }
public override void Rollback(IDictionary savedState)
{
base.Rollback(savedState);
}
}
}
通过CheckSerail()方法验证用户输入的序列号与我数据库里的用来保存序列号的表中是否匹配,但是在安装的过程中,报了一个 "1001 未将对象引用设置到对象的实例" 的错,可能和SerialBLL 有关,还请各位大神帮忙,在下新手,入行不深,或者有更好的建议可以做出这种效果的话,还请指教,感激不敬!!!!
写了安装程序类,如下
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
using System.Linq;
using System.Windows.Forms;
using BLL;
namespace Install
{
[RunInstaller(true)]
public partial class MyInstaller : Installer
{
public MyInstaller()
{
InitializeComponent();
}
protected override void OnAfterInstall(IDictionary savedState)
{
base.OnAfterInstall(savedState);
}
public override void Install(IDictionary stateSaver)
{
base.Install(stateSaver);
BLL.SerialBLL bll = new SerialBLL();
string message = Context.Parameters["message"].ToString();
MessageBox.Show(message);
if (bll.CheckSerail(message) == true)
{
MessageBox.Show("激活成功"); }
else
{
MessageBox.Show("激活失败");
return;
}
}
protected override void OnBeforeInstall(IDictionary savedState)
{ base.OnBeforeInstall(savedState); }
public override void Uninstall(IDictionary savedState)
{
base.Uninstall(savedState); }
public override void Rollback(IDictionary savedState)
{
base.Rollback(savedState);
}
}
}
通过CheckSerail()方法验证用户输入的序列号与我数据库里的用来保存序列号的表中是否匹配,但是在安装的过程中,报了一个 "1001 未将对象引用设置到对象的实例" 的错,可能和SerialBLL 有关,还请各位大神帮忙,在下新手,入行不深,或者有更好的建议可以做出这种效果的话,还请指教,感激不敬!!!!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货