高分求解VS2005打包后安装的问题
用VS2005做了个打包的程序,但是在安装时出现错误:DIYINSTALLER_BeforeInstall事件处理程序发生错误-->>未将未将对象引用设置到对象实例.恳请高人指点,谢谢!!源代码如下:
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Configuration.Install
Imports Microsoft.VisualStudio.Tools.Applications.Runtime
Imports System.Runtime.InteropServices
Public Class DIYINSTALLER
Inherits System.Configuration.Install.Installer
Public Sub New()
'MyBase.New()
'组件设计器需要此调用。
InitializeComponent()
AddHandler Me.BeforeInstall, AddressOf DIYINSTALLER_BeforeInstall
AddHandler Me.AfterInstall, AddressOf DIYINSTALLER_AfterInstall
'调用 InitializeComponent 后添加初始化代码
End Sub
'重写基类的INSTALL方法
Public Overrides Sub Install(ByVal stateSaver As System.Collections.IDictionary)
MyBase.Install(stateSaver)
End Sub
<DllImport("mscoree.dll")> _
Friend Shared Sub GetCORSystemDirectory(<Runtime.InteropServices.MarshalAs( _
System.Runtime.InteropServices.UnmanagedType.LPWStr)> _
ByVal Buffer As System.Text.StringBuilder, _
ByVal BufferLength As Integer, ByRef Length As Integer)
End Sub
Private Sub DIYINSTALLER_AfterInstall(ByVal sender As Object, ByVal e As System.Configuration.Install.InstallEventArgs)
'获得Caspol工具所在的文件路径
Dim sPath As System.Text.StringBuilder = New System.Text.StringBuilder(1024)
Dim size As Integer = 0
GetCORSystemDirectory(sPath, sPath.Capacity, size)
sPath.Append("Caspol.exe")
'获得安装程序的目标路径
Dim sUrl As String = Me.Context.Parameters("targetdir").Trim("/")
sUrl += "*"
'设置Caspol的命令参数
Dim sPar As System.Text.StringBuilder = New System.Text.StringBuilder("-q -u -ag All_Code -url ")
sPar.Append(sUrl)
sPar.Append(" FullTrust")
sPar.Append(" -n")
sPar.Append(" ExcelAppDiy")
'执行Caspol命令来配置权限
System.Diagnostics.Process.Start(sPath.ToString(), sPar.ToString())
End Sub
Private Sub DIYINSTALLER_BeforeInstall(ByVal sender As Object, ByVal e As System.Configuration.Install.InstallEventArgs)
'获得Caspol工具所在的文件路径
Dim sPath As System.Text.StringBuilder = New System.Text.StringBuilder(1024)
Dim size As Integer = 0
GetCORSystemDirectory(sPath, sPath.Capacity, size)
sPath.Append("Caspol.exe")
'执行Caspol命令来取消权限
System.Diagnostics.Process.Start(sPath.ToString(), "-q -u -rg ExcelAppDiy")
End Sub
End Class
--------------------编程问答-------------------- 版主,请帮忙 --------------------编程问答-------------------- 顶 --------------------编程问答-------------------- 顶 --------------------编程问答-------------------- 顶
--------------------编程问答-------------------- 关注,学习 --------------------编程问答-------------------- 未将未将对象引用设置到对象实例.
说明引用出错了,如果就用默认的方式打包,一般不会出错,要另加代码,就是引用文件出错了,
从提示看,你使用了自定义的打包,检查定义的代码引用。 --------------------编程问答-------------------- 这个难说
补充:.NET技术 , VB.NET