Prev: issue when using functions (having CString& type parameter) from C++ dll in to C#
Next: ExecuteScalar
From: sebastian.dau on 23 Dec 2009 13:29 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: sebastian.dau on 11 Jan 2010 11:16
On 23 Dez. 2009, 19:29, "sebastian....(a)googlemail.com" <sebastian....(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. > > 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 > () Hello NG, finally I got it solved. My observations where a little missleading here. I figured out that one of our MSI's did include deployment of iphlpapi.dll. When that lib file is taken from an WinXp system and deployed and used on Win7 the upper function failes because of incompatibility. Solutution is to remove local copies of the lib and make the system use the one that comes with the OS. |