Class not registered error after migration - vb.net

Issue with custom VB.net solution after moving user to new Windows 10.
Removing, re-adding various references. Cleaning and Rebuilding.
Public Class mainForm
Dim exc As Excel.Application
Dim wd As Word.Application
Private wsClient As New WebClient()
Dim customAccForm As New customAccessories
Dim custNumArray(4200) As String
Dim preload As Boolean = False
Public custName As String = ""
Public custPhone As String = ""
Public custAddy, custSuite, custCity As String
Dim accessoriesprice, accessoriesWeight As Double
Dim chkQty(20), chkPrc(20), chkWt(20) As Double
Dim chkCtr As Integer = 0
Dim chkDsc(20) As String
Dim currName As String
Dim updateQuotes As Boolean
Dim thr, thr2 As Threading.Thread
Dim bodyTxt, quotedFreight As String
Public USPS_UserID As String = "USERNAME"
I've moved a user from an older Windows 7 machine to a new windows 10 machine. I have a custom built VB.net application that will not compile on the new machine. I get a "class not registered" message and the debugger highlights a variable declaration at the top of Forms class. What's weird is it is on a declaration for a String, the USPS_UserID declaration in the code above. Even weirder is that I can reorder my declarations and it will show the registration error for another class (String, Integer, Double). It varies.

Related

Vb.NET Device Unique Identifier Win10

I'm trying to get a Device Unique Identifier in vb.net code. I have tried with
Private Function SystemSerialNumber() As String
Dim value As String = ""
Dim baseBoard As ManagementClass = New ManagementClass("Win32_BaseBoard")
Dim board As ManagementObjectCollection = baseBoard.GetInstances()
If board.Count > 0 Then
value = board(0)("SerialNumber")
If value.Length > 0 Then value = value.Substring(2)
End If
Return value
End Function
Which works on some computers but of the board doesn't have a serial number it returns "Default String" or whatever they put in there. Even tried with Win32_Processor and some have it and others just return "To be filled by O.E.M" lol
Also tried with,
Private Function SystemSerialNumber() As String
Dim value As String
Dim q As New SelectQuery("Win32_bios")
Dim search As New ManagementObjectSearcher(q)
Dim info As New ManagementObject
For Each info In search.Get
value = info("SerialNumber").ToString
Return value
Next
End Function
But its the same some devices have it some don't and just returns default string.
So I'm now trying is:
Private Function SystemSerialNumber() As String
Dim value As String
value = Windows.System.Profile.SystemIdentification.GetSystemIdForPublisher()
End Function
But I'm having trouble referencing to it. I tried Imports Windows.System but it just gives the error it cant be found.
As a side note I'm using this program in tablets with windows10, laptops, and desktops.
UPDATE: I'll be using as suggested by Heinzi. Thanks!
Also changed variable names to be more accurate.
Private Function NetworkAdapterMacAddress() As String
Dim McAddress As String
Dim netadapter As ManagementClass = New ManagementClass("Win32_NetworkAdapterConfiguration")
Dim mo As ManagementObject
Dim adapter As ManagementObjectCollection = netadapter.GetInstances()
For Each mo In adapter
If mo.Item("IPEnabled") = True Then
McAddress = mo.Item("MacAddress").ToString()
Return McAddress
End If
Next
End Function
Well, there is no guaranteed ID that identifies every PC out there uniquely (fortunately, I might add. Privacy is a good thing).
You best bets are probably
the MAC of the network adapter (changes when the network adapter is replaced) or
the Windows Computer SID (changes when Windows is reinstalled).
Oh, and on a philosophical note, you might want to ponder on the Ship of Theseus.

Get Result of Private Property TcpClient.BeginConnect, IAsyncResult in VB.NET

I have an application in VB.NET When I run the application in Visual Studio 2010 and mouseover an IAsyncResult, I see the protected property Result. I would like to read the value of the property in the application. How can I do that?
Imports System.Net
Imports System.Net.Sockets
...
Friend Function StartSendGo() As String
'Declarations
Dim strSendMachineName As String = "DEV001"
Dim intSendPort As Integer = 50035
Dim socketclient As New System.Net.Sockets.TcpClient()
Dim rslt As IAsyncResult = tcpClient.BeginConnect(strSendMachineName, intSendPort, New AsyncCallback(AddressOf ConnectCallback), socketclient)
Dim blnSuccess = rslt.AsyncWaitHandle.WaitOne(intTimeOutConnect, True)
'HERE is where I need rslt.Result.Message
End Function
Public Function ConnectCallback()
'Placeholder
End Function
When I mouseover rslt, VS shows that it is of type
System.Net.Sockets.Socket+MultipleAddressConnectAsyncResult I have never seen a plus (+) in a type before, and I am not able to declare a variable of that type. If I expand the properties, there is a protected property Result, which has a property Message with a value of "No connection could be made because the target machine actively refused it 192.0.0.10:50035". I need access to that message. I would also like to access addresses, but that is less important.
I found a solution - to use Reflection to read the value of the private property.
'Imports
Imports System.Reflection
'Call functions that write to rslt
rslt = tcpClient.BeginConnect(strSendMachineName, intSendPort, New AsyncCallback(AddressOf ConnectCallback), socketclient)
blnSuccess = rslt.AsyncWaitHandle.WaitOne(intTimeOutConnect, True)
'Use Reflection
'Get Type
Dim myType As Type = rslt.GetType()
'Get properties
Dim myPropertyInfo As PropertyInfo() = myType.GetProperties((BindingFlags.NonPublic Or BindingFlags.Instance))
'The order of the properties is not guaranteed. Find by name.
For Each pi As PropertyInfo In myPropertyInfo
If pi.Name = "Result" Then
'TODO Add check for nothing.
'Assign to Exception-type variable.
exException = pi.GetValue(rslt, Nothing)
End If
Next

Can I add an object to a struct in VB.net?

I have a data struct for a piece of lumber. I've built a class to handle dimensions (architectural, metric, etc... ) that I'd like to make the data type of the length member of this struct. VB says I can't use 'new' in my definition unless I make the member 'Shared'. If I make the member 'Shared' I can't see the data when I try to access the member in my code.
Public Structure PieceInfo
Dim ProjectNumber As String
Dim ProjectName As String
Dim BuildingType As String
Dim BuildingNumber As String
Dim BLevel As String
Dim Batch As String
Dim Trussname As String
Dim Span As Single
Dim PieceName As String
Dim LumberType As String
Shared PieceLength As New clsDimension
Shared StockLength As New clsDimension
Dim LeftSplicePlate As String
Dim RightSplicePlate As String
End Structure
How can I use my "clsDimension" object as the data type for the "Length" members of my struct?
As all the comments indicate: You should change your Struct to a class because you want to reference it. And due to Structs being value types and Classes being reference types, This is what you want:
Public Class PieceInfo
Dim ProjectNumber As String
Dim ProjectName As String
Dim BuildingType As String
Dim BuildingNumber As String
Dim BLevel As String
Dim Batch As String
Dim Trussname As String
Dim Span As Single
Dim PieceName As String
Dim LumberType As String
Shared PieceLength As New clsDimension
Shared StockLength As New clsDimension
Dim LeftSplicePlate As String
Dim RightSplicePlate As String
End Class
.NET Structure don't have default constructor, you'll have to create your own (or a function to initialize the values). But that kind of defeat the purpose of the struct.
Public Structure PieceInfo
Dim ProjectNumber As String
Dim ProjectName As String
Dim BuildingType As String
Dim BuildingNumber As String
Dim BLevel As String
Dim Batch As String
Dim Trussname As String
Dim Span As Single
Dim PieceName As String
Dim LumberType As String
Dim PieceLength As clsDimension
Dim StockLength As clsDimension
Dim LeftSplicePlate As String
Dim RightSplicePlate As String
Public Sub New(ByVal t As String)
PieceLength = New clsDimension
StockLength = New clsDimension
End Sub
End Structure
But like others said, changing it to a class is the right thing to do. Class is reference type and structure is value type.

How do i unlabel a file using the TFS sdk and vb.net

I'm in the process of writing a little app for our SQL developers to allow them to create labels with TFS for easy code deployment, the trouble is the .ssmssqlproj files are being added to the label when ever i create one. I've added a sub to loop through and unlabel these file but i just will not work. code below
Public Sub UnlabelItem()
Dim returnValue As LabelResult()
Dim labelName As String = "1208-2210"
Dim labelScope As String = "$/"
Dim version As VersionSpec = New LabelVersionSpec(labelName, labelScope)
Dim path As String = "$/FEPI/Database/FEPI/000 Pre Tasks.ssmssqlproj"
Dim recursion As RecursionType = RecursionType.None
Dim itemspec As ItemSpec = New ItemSpec(path, recursion)
returnValue = sourceControl.UnlabelItem(labelName, labelScope, itemspec, version)
End Sub
this is a test Sub just to get it working and this is the error i get
Value of type 'Microsoft.TeamFoundation.VersionControl.Client.ItemSpec' cannot be converted to '1-dimensional array of Microsoft.TeamFoundation.VersionControl.Client.ItemSpec'
HAs anybody had any luck with the unlabel command?
Matt

visual basic error in referencing SNMP class

I have created an SNMP class
And then i want to test this class,so I create a program which imports this class…
Imports SNMPClass
Module Module1
End Module
Public Class SimpleSNMP
Public Sub Main(ByVal argv As String())
Dim commlength As Integer, miblength As Integer, datatype As Integer, datalength As Integer, datastart As Integer
Dim uptime As Integer = 0
Dim output As String
Dim response As Byte() = New Byte(1023) {}
Dim conn As New SNMP()
Console.WriteLine("Device SNMP information:")
' Send sysName SNMP request
response = conn.[get]("get", argv(0), argv(1), "1.3.6.1.2.1.1.5.0")
If response(0) = &HFF Then
Console.WriteLine("No response from {0}", argv(0))
Return
End If
............
I got an error in this line
Dim conn As New SNMP()
Which says “SNMPClass.SNMP is not accessible in this context because it is friend”..
I m using Visual Studio 2008
While I don't have all of your code to verify this is the case, I believe the following article from Microsoft about this error will address your issue:
http://support.microsoft.com/kb/814319