Function expecting System.Guid - invalid cast problem

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
 
M

Marina

Turn Option Strict On. Odds are you will find the error at compile time,
perhaps it is happening elsewhere.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top