Function expecting System.Guid - invalid cast problem

  • Thread starter Thread starter crawfordn
  • Start date Start date
C

crawfordn

Hi there,

I'm trying to utilize the WSUS API to create my own custom reporting
agents.

I'm using iUpdateServer.GetComputerTargetGroup, which is defined as
follows:
Public Function GetComputerTargetGroup( _
ByVal id As Guid _
) As IComputerTargetGroup
Implements IUpdateServer.GetComputerTargetGroup

My code is as follows:
For Each targetGroup As IComputerTargetGroup In ComputerGroups
Computers = iUpdateServer.GetComputerTargetGroup(targetGroup.Id)
....

targetGroup.Id is of type System.Guid. Whenever I pass targetGroup.id
to the GetComputerTargetGroup function, I get the following error:

System.InvalidCastException: Specified cast is not valid.

Any ideas as to what I'm doing wrong?

Thank you for any help!
--Nick
 
Turn Option Strict On. Odds are you will find the error at compile time,
perhaps it is happening elsewhere.
 
Back
Top