VB.NET浮动网络许可服务代码BC32035错误原因咨询
错误BC32035:Attribute specifier is not a complete statement的原因及解决方法
错误原因
在VB.NET中,属性声明的行续符(下划线_)必须直接衔接目标代码,不能单独占一行,也不能在续行符和目标代码之间留空行。你的代码里<RunInstaller(True)> _单独占了一行,后面空了一行才是Public Class ProjectInstaller,编译器无法识别这个属性是要应用到后续的ProjectInstaller类上,因此抛出该错误。
解决方法
有两种修正方式:
- 将属性与类定义放在同一行:
<RunInstaller(True)> Public Class ProjectInstaller
- 保留行续符,但确保续行符后直接衔接类定义,无空行:
<RunInstaller(True)> _ Public Class ProjectInstaller
修正后的完整ProjectInstaller代码
Imports System.ComponentModel Imports System.Configuration.Install Imports System.ServiceProcess <RunInstaller(True)> _ Public Class ProjectInstaller Inherits Installer Private serviceInstaller As ServiceInstaller Private processInstaller As ServiceProcessInstaller Public Sub New() processInstaller = New ServiceProcessInstaller() serviceInstaller = New ServiceInstaller() ' 服务将在系统账户下运行 processInstaller.Account = ServiceAccount.LocalSystem ' 服务信息配置 serviceInstaller.DisplayName = "License Server Service" serviceInstaller.StartType = ServiceStartMode.Automatic serviceInstaller.ServiceName = "LicenseServerService" ' 将安装器添加到集合,顺序不影响 Installers.Add(serviceInstaller) Installers.Add(processInstaller) End Sub End Class
内容的提问来源于stack exchange,提问作者Graham
相关产品推荐
相关产品推荐

