Hrmm...Jag hade en refererat en dll som var för v4.0 och kompilerade med v2.0 :-\
Edit:
Nope! Var tydligen det också...
mao Det har inte löst problemet. Var lite snabb där.
3 svar · 1 230 visningar · startad av ironhead
Hej alla glada människor!
Jag har skrivit en windows service där jag lagt till en "ServiceProcessInstaller" så att jag kan använda "Installutil" för att installera den på servern.
Problemet är att om jag kör "Code Analysis" (VS.NET 2010) så får jag två varningar som ser ut som nedan:
Warning 2 CA2214 : Microsoft.Usage : 'ProjectInstaller.New()' contains a call chain
that results in a call to a virtual method defined by the class. Review the following call
stack for unintended consequences:
ProjectInstaller..ctor()
ProjectInstaller.InitializeComponent():Void
ProjectInstaller.get_ServiceProcessInstaller1():ServiceProcessInstaller
Kan man göra något för att slippa få varningar från denna? Eller ska man bara acceptera detta?
Hrmm...Jag hade en refererat en dll som var för v4.0 och kompilerade med v2.0 :-\
Edit:
Nope! Var tydligen det också...
mao Det har inte löst problemet. Var lite snabb där.
Mm, det är som det står, det är inte bra att konstruktorn anropar en virtual metod.
Eller rättare sagt det kan leda till konstigheter om man gör dumma saker i virtualmetoden.
Jag körde enligt detta:
The Windows Service requires extra code to be able to be installed onto a Windows machine.
1. Add a new item to the project of the type Installer Class. Name this class ProjectInstaller.vb.
2. Add System.ServiceProcess.ServiceInstaller and System.ServiceProcess.ServiceProcessInstaller.
Configure the ServiceInstaller:
Under the toolbox section Visual Basic PowerPacks, drag a ServiceInstaller into the
ProjectInstaller.vb design window.
Right-click on it and select Properties.
Verify that the Parent property is set to ProjectInstaller.
Change the Service Name property to what you want the service to be called within the
list of services in Windows.
Change the StartType property using the drop-down to Automatic.
Configure the ServiceProcessInstaller:
Under the toolbox section Visual Basic PowerPacks, drag a ServiceProcessInstaller
into the ProjectInstaller.vb design window.
Right-click on it and select Properties.
Change the Parent property to ProjectInstaller.
Change the Account property to LocalSystem.
You can now use the InstallUtil.exe program to install your Windows Service.
Sen direkt när jag körde "Code Analysis", fick jag ovanstående fel.