Bonjour,

J'utilise Visual Studio .NET 2003.

Je souhaite utiliser ce script pour tester une connexion a un serveur HTTP distant en tenant compte de la configuration du système (configuration par script PAC ou proxy d'Internet Explorer).

Le code suivant fonctionne parfaitement dans un application de type winform ou console mais ne fonctionne pas dans un service Windows.

Dim HttpRequest = CreateObject("MSXML2.XMLHttp.5.0")
HttpRequest.open("HEAD", "http://www.google.fr", False)
HttpRequest.send()

Dim eventLog As New EventLog
eventLog.Source = "Demo"
eventLog.WriteEntry(HttpRequest.status & " " & HttpRequest.statusText)
eventLog.Close()

Le code ci-dessus génère le message d'erreur suivant lorsqu'il est placé dans la methode OnStart d'un service Windows:

Service cannot be started. System.Runtime.InteropServices.COMException (0x800C0005): The system cannot locate the resource specified.

at Microsoft.VisualBasic.CompilerServices.LateBinding.InternalLateCall(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack, Boolean IgnoreReturn)
at Microsoft.VisualBasic.CompilerServices.LateBinding.LateCall(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack)
at WindowsService1.Service1.OnStart(String[] args)
at System.ServiceProcess.ServiceBase.ServiceQueuedMainCallback(Object state)

Pour plus d'informations, consultez le centre Aide et support à l'adresse http://go.microsoft.com/fwlink/events.asp.


Merci d'avance.