Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Weird situation passing an integer to a Web Service
Message
De
18/01/2005 04:27:12
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
Weird situation passing an integer to a Web Service
Divers
Thread ID:
00977986
Message ID:
00977986
Vues:
82
I am using reflection to call a Web Service method and I am facing a weird situation when passing some parameters that require an integer. If I call the Web Service like this, it works:
                Dim loType As Type = loWebService.GetType()
                Dim loInfo As System.Reflection.MethodInfo = loType.GetMethod(lcMethod)
                Dim loParameter(1) As Object
                loParameter(0) = Date.Today
                loParameter(1) = 5
                lcXMLReturned = loInfo.Invoke(loWebService, loParameter)
In this case, the method called requires a date and an integer. Keeping the same method, if I do this, it won't work:
                Dim loType As Type = loWebService.GetType()
                Dim loInfo As System.Reflection.MethodInfo = loType.GetMethod(lcMethod)
                Dim loParameter(1) As Object
                loParameter(0) = Date.Today
                loParameter(1) = Val(lcParameterActual)
                lcXMLReturned = loInfo.Invoke(loWebService, loParameter)
Even if lcParameterActual is equal to "5", making it Val(), won't work. During the Invoke(), I will obtain:

"Cannot widen from target type to primitive type"

I tried putting Int() instead of Val(). This gave the same reaction.

How can I convert my string to something that will work using reflection?
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform