473,513 Members | 2,368 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

WMI and Win32_NetworkAdapterConfiguration - System.InvalidCastException: Cast from string to Date

Hi,

I am using the WMI management object to obtain values about the network
cards installed on the system.

The MSDN tells me the following
class Win32_NetworkAdapterConfiguration : CIM_Setting
{
...
datetime DHCPLeaseExpires;
datetime DHCPLeaseObtained;
...
};
When I use the following code

Dim dExpires as DateTime
dExpires = CType(wmi.Item("DHCPLeaseExpires"), DateTime)

I Get the following exception

System.InvalidCastException: Cast from string
"20041109122048.000000+120" to type 'Date' is not valid.
at Microsoft.VisualBasic.CompilerServices.DateType.Fr omString(String
Value, CultureInfo culture)
at Microsoft.VisualBasic.CompilerServices.DateType.Fr omString(String
Value)
at Microsoft.VisualBasic.CompilerServices.DateType.Fr omObject(Object
Value)
at Assimilator.SDK.clsNICProperties.PopulateNetworkAd apterArray() in
V:\VBNET\Assimilator Ver 4.2\Assimilator.SDK\clsNICProperties.vb:line
212
How do I fix ?????

:)

Thank You
Mark Hollander

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #1
1 2952
"Mark Hollander" <ma**@atcom.co.za> schrieb:
Dim dExpires as DateTime
dExpires = CType(wmi.Item("DHCPLeaseExpires"), DateTime)

I Get the following exception

System.InvalidCastException: Cast from string


Take a look at the 'System.Management.ManagementDateTimeConverter' class.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
8214
by: karunakar | last post by:
Hi All Here iam getting this Error "Specified cast is not valid." My Project has Onc solution diffrent class libarary In that solution DALfactory solution iam getting this error I was calling...
1
4847
by: Hifni Shahzard | last post by:
Hi, I got a stored procedure, where it returns a value. But if I execute it. It gives an error as "Invalid cast from System.Int32 to System.Byte.". To make clear how do I execute this, below I'm...
4
2647
by: DOTNET | last post by:
Hi, Anybody help me regarding this error: I am assigning the values to the session variables when the button is clicked and passing these session variables to the next page and when I am...
10
4001
by: Kiran | last post by:
Hi, I am trying to convert a string(Thu Jul 21 00:00:00 UTC+0100 200) to date. I get the following error Cast from string "Thu Jul 21 00:00:00 UTC+0100 200" to type 'Date' is not...
2
13544
by: John Smith | last post by:
I'm writing webervice client using .Net 2.0. I have this class: public class MyWebService : SoapHttpClientProtocol { public XmlDocument validate(string url, XmlDocument xmlDocument) {...
1
5144
by: Ratz | last post by:
Hello everyone! I'm new to this Forum! I've spent about 56 hours trying to solve a .NET VB Runtime error while Using a program.Ive contacted the developer of the program and he could not figure out...
8
4248
by: Gamma | last post by:
I'm trying to inherit subclass from System.Diagnostics.Process, but whenever I cast a "Process" object to it's subclass, I encounter an exception "System.InvalidCastException" ("Specified cast is...
4
1834
by: rsdev | last post by:
Hi, I have an InvalidCastException which is completely puzzling me. I have checked all the members in the stored procedure against my data provider and seems to be ok. Also in the stack trace it...
2
2490
by: thithi | last post by:
Server Error in '/Assignment' Application. -------------------------------------------------------------------------------- Specified cast is not valid. Description: An unhandled exception...
0
7267
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7175
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7120
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7542
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5697
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5100
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3247
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3235
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1609
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.