Fail to get global DateTime after upgrade to Inventor 2025

Fail to get global DateTime after upgrade to Inventor 2025

Maxim-CADman77
Advisor Advisor
218 Views
1 Reply
Message 1 of 2

Fail to get global DateTime after upgrade to Inventor 2025

Maxim-CADman77
Advisor
Advisor

One of my projects needs to know global DateTime and I used to get it from internet with vb.Net code like:

 

Imports System.Net.Sockets ' allows to use TcpClient for Inventor 2024 and earlier

Dim globDateStr As String
Dim servDT As DateTime

Try

	Dim ntpServURL As String = "time.nist.gov"

	Dim streamR As IO.StreamReader

	streamR = New IO.StreamReader(New TcpClient(ntpServURL, 13).GetStream) ' ?? "Type 'TcpClient' is not defined" in Inventor 2025

	If streamR Is Nothing Then
		MessageBox.Show("No internet access")
		RETURN
	End If

	Dim servRespStr As String = streamR.ReadToEnd()

	Logger.Info("NTP-server respond string:" & servRespStr)

	streamR.Close()

	servDT = "20" & servRespStr.Substring(7, 18)
	globDateStr = servDT.ToShortDateString()

Catch ex As Exception
	Logger.ERROR(ex.Message)
	globDateStr = "UNKNOWN"
End Try

MsgBox("Global Date is " & globDateStr)

 

But line 12 produces exception "Type 'TcpClient' is not defined" in Inventor 2025 (I believe because of its upgrade to .Net 8).

 

I'd like to know how to get global DateTime in Inventor 2025.

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
Accepted solutions (1)
219 Views
1 Reply
Reply (1)
Message 2 of 2

Michael.Navara
Advisor
Advisor
Accepted solution

Just add this line at the beginning

AddReference "System.Net.Sockets.dll"

 

0 Likes