Super Principiante // Uso il framework ASP.NET (webmatrix)e attraverso esso e la sua guida sto studiando il codice vb.net (ma non ho il programma di quest’ultimo)
Studiando il codice di esempio sottostante non ho trovato nello spazio dei nomi il riferimento relativo alla parola ImyExtenderInterface (durante la compilazione mi dice che non è definita), quindi ho pensato che forse essa è un’interfaccia personalizzata, cioè creata dall’utente.
Vorrei sapere da voi se ho pensato giusto e se sì come faccio a creare delle interfacce personalizzate? Chi mi spiega il codice sottostante? Come faccio a farlo funzionare?
codice:
Imports System
Imports System.Reflection ' serve x le enumerazioni BinderFlags
Module module1
sub Main()
Dim hdlSample As System.Runtime.Remoting.ObjectHandle
'Dim myExtenderInterface As IMyExtenderInterface
Dim argOne As String = "Value of argOne"
Dim argTwo As Integer
argTwo = 7
Dim args As Object() = {argOne, argTwo}
dim UrlAttribute() as System.Runtime.Remoting.Activation.UrlAttribute
' Uses the UrlAttribute to create a remote object.
Dim activationAttributes() = New UrlAttribute("http://localhost:9000/MySampleService")
' Activates an object for this client.
' You must supply a valid fully qualified assembly name here.
hdlSample = System.Activator.CreateInstance("Assembly text name, Version, Culture, PublicKeyToken", "samplenamespace.sampleclass", True, BindingFlags.Public, Nothing, args, Nothing, activationAttributes, Nothing)
myExtenderInterface = CType(hdlSample.Unwrap(), IMyExtenderInterface)
Console.WriteLine(myExtenderInterface.SampleMethod("Bill"))
end sub
end module