[Winpcap-users] WinPCap & Managed Extensions
Alessandro Baldisserri
bujia at libero.it
Wed Oct 12 15:24:19 GMT 2005
Thanks fou your detailed answer.
I develop my service with Visual C++ .NET, with WindowsService procedure.
In my project I refer to wpcap.lib and consequentially to wpcap.dll, further more I refer to packet.lib and consequentially to packet.dll. I don't use wanpacket.dll, and NM driver. So in service dependecies I inserted NPF but result was the same. I start NPF automatically at boot. In windows XP I don't how to set startup of a driver at boot, but I change in the Registry, on the Value "Start" of the key associated with the driver NPF, I put 1, that mean "start at boot". It's correct? I think yes, but result is the same....service start and stop with an error... I post the error:
Not able to start service. System.TypeLoadException: not able to load type pcap on assembly MyService, Version=1.0.2111.29138, Culture=Neutral, PublicKeyToken=null.
at MyService.OnStart(String[] args)
at System.ServiceProcess.ServiceBase.ServiceQueuedMainCallback (Object state)
I hope that you understand a bit what's my problem...I don't how to proceed...
Thanks in advance.
Alessandro
---------- Initial Header -----------
>From : winpcap-users-bounces at winpcap.org
To : winpcap-users at winpcap.org
Cc :
Date : Tue, 11 Oct 2005 18:34:59 -0400
Subject : Re: [Winpcap-users] WinPCap & Managed Extensions
> Loris Degioanni wrote:
> > If I remember well, the article at:
> >
> > http://www.codeproject.com/dotnet/dotnetwinpcap.asp
> >
> > explains how to use WinPcap from .net.
>
> ... Now that I think about it, I think I know what the problem in this
> thread is. It's probably that either the NPF or NM driver (or both)
> haven't been started before Alessandro's service tries to start.
>
> The main WinPcap DLL starts NPF when it gets loaded, and one of the
> dependencies of wanpacket.dll starts NM when it gets loaded. If the
> service's executable explicitly links against the WinPcap DLLs (which I
> think you can do in C++, but not C# or VB.net), then the service process
> itself will load those DLLs when it starts, which will try to start both
> of those drivers.
>
> But the drivers take a *long* time to start (at least on 2000 Pro),
> because the OS is under heavy service-start load at boot time.
>
> The solution is to either mark your service as depending on both NPF and
> NM, or mark NPF and NM as "system" or (maybe) "boot". That will make
> them start before the service's EXE even tries to load, so the DLL load
> time will be drastically reduced. So the service will be able to call
> StartServiceCtrlDispatcher earlier, and not have its process killed by SCM.
>
> To mark them as system (again, on 2K Pro), bring up device manager,
> select View -> Show nonpresent devices, then expand "non-PnP devices"
> and go to the properties on both the "NetGroup Packet Filter" and
> "Network Monitor" items, then go to the "Driver" tab inside the dialog,
> and change the startup type from "Demand" to "System" on both items.
>
More information about the Winpcap-users
mailing list