From: sebastian.dau on
Hi News Group,

I'm writing some code that discovers network interfaces and devices.
It works correct when executed in a console application (managed)
but it fails when executed from a managed windows service.
The service is configured to run as local service so I guess that is
enough permission to perform the operations.


Does anybody know how to discover network info from a windows service
and why my code does fail ???


See stack for info.


Even though it's managed code I know that the underlying function is
pure win api and the source of the error.


System.Net.NetworkInformation.NetworkInformationException: The data
is
invalid
at
System.Net.NetworkInformation.SystemNetworkInterface.GetAdaptersAddresses
(AddressFamily family, FixedInfo fixedInfo)
at
System.Net.NetworkInformation.SystemNetworkInterface.PostWin2KGetNetworkInt­
erfaces
(AddressFamily family)
at
System.Net.NetworkInformation.SystemNetworkInterface.GetNetworkInterfaces
(AddressFamily family)
at
System.Net.NetworkInformation.SystemNetworkInterface.GetNetworkInterfaces
()
at
System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces
()
From: Family Tree Mike on
On 1/4/2010 10:07 AM, sebastian.dau(a)googlemail.com wrote:
> Hi News Group,
>
> I'm writing some code that discovers network interfaces and devices.
> It works correct when executed in a console application (managed)
> but it fails when executed from a managed windows service.
> The service is configured to run as local service so I guess that is
> enough permission to perform the operations.
>

I wouldn't make the assumption that the service has sufficient
permission. I think you should try running the service with your login
info and see if the problem persists.


--
Mike