Créer l'équivalent d'une dll Activex, utilisable dans une page Asp avec Visual B

Signaler
Messages postés
1
Date d'inscription
jeudi 6 novembre 2003
Statut
Membre
Dernière intervention
15 mars 2006
-
Messages postés
181
Date d'inscription
jeudi 27 février 2003
Statut
Membre
Dernière intervention
2 mars 2009
-
Hello tout le monde !

Voilà mon problème :
J'ai besoin de créer une dll qui puisse être appelée dans un page Asp (en faisant un Server.createObject) à l'aide de Visual Basic 2005 Express

Cette dll, utilise elle-même une dll contenant des fonctions de codage de trame (il s'agit de la dll payboxppps.dll, pour ceux qui connaissent)
J'ai donc créé une dll contenant une structure de trame ainsi qu'une fonction d'appel de codage.

Voici le code de ma dll :

Option Strict Off
Option Explicit On

Imports System.Runtime.InteropServices

<System.Runtime.InteropServices.ProgId("Paybox.Appel")> Public Class Appel
Inherits System.EnterpriseServices.ServicedComponent

Private myversion_tc As String
Private mydateq_tc As String
Private mytype_tc As String
Private mynumquestion_tc As String
' informations sur le commerçant
Private mysite_tc As String
Private myrang_tc As String
Private mycle_tc As String
Private myidentifiant_tc As String
' informations sur la transction
Private mymontant_tc As String
Private mydevise_tc As String
Private myreference_tc As String
Private myporteur_tc As String
Private mydateval_tc As String
Private mycvv_tc As String
Private myactivite_tc As String
Private myarchivage_tc As String
' informations sur les opérations précédentes
Private mynumappel_tc As String
Private mynumtrans_tc As String
Private myautorisation_tc As String
Private mycodereponse_tc As String
Private mycommentaire_tc As String
' informations de communication
Private myserveurip_tc As String
Private myserveurport_tc As String

Private Structure tyTramePPPS
' informations générales
Public VERSION_TC As String
Public DATEQ_TC As String
Public TYPE_TC As String
Public NUMQUESTION_TC As String
' informations sur le commerçant
Public SITE_TC As String
Public RANG_TC As String
Public CLE_TC As String
Public IDENTIFIANT_TC As String
' informations sur la transction
Public MONTANT_TC As String
Public DEVISE_TC As String
Public REFERENCE_TC As String
Public PORTEUR_TC As String
Public DATEVAL_TC As String
Public CVV_TC As String
Public ACTIVITE_TC As String
Public ARCHIVAGE_TC As String
' informations sur les opérations précédentes
Public NUMAPPEL_TC As String
Public NUMTRANS_TC As String
Public AUTORISATION_TC As String
Public CODEREPONSE_TC As String
Public COMMENTAIRE_TC As String
' informations de communication
Public SERVEURIP_TC As String
Public SERVEURPORT_TC As String
End Structure

' Déclaration des fonctions de la librairie PAYBOX
' dans cet exemple on utilise une seule fonction de la dll qui est 'appel_ppps'
Private Declare Function appel_ppps Lib ".\payboxppps.DLL" (ByRef question_st As tyTramePPPS) As Short

' Variable d'échange PPPS
Private tpPaybox As tyTramePPPS

Public Property VERSION_TC() As String
Get
VERSION_TC = myversion_tc
Exit Property
End Get
Set(ByVal Value As String)
myversion_tc = VERSION_TC
Exit Property
End Set
End Property

Public Property DATEQ_TC() As String
Get
DATEQ_TC = mydateq_tc
Exit Property
End Get
Set(ByVal Value As String)
mydateq_tc = DATEQ_TC
Exit Property
End Set
End Property

Public Property TYPE_TC() As String
Get
TYPE_TC = mytype_tc
Exit Property
End Get
Set(ByVal Value As String)
mytype_tc = TYPE_TC
Exit Property
End Set
End Property

Public Property NUMQUESTION_TC() As String
Get
NUMQUESTION_TC = mynumquestion_tc
Exit Property
End Get
Set(ByVal Value As String)
mynumquestion_tc = NUMQUESTION_TC
Exit Property
End Set
End Property

Public Property SITE_TC() As String
Get
SITE_TC = mysite_tc
Exit Property
End Get
Set(ByVal Value As String)
mysite_tc = SITE_TC
Exit Property
End Set
End Property

Public Property RANG_TC() As String
Get
RANG_TC = myrang_tc
Exit Property
End Get
Set(ByVal Value As String)
myrang_tc = RANG_TC
Exit Property
End Set
End Property

Public Property CLE_TC() As String
Get
CLE_TC = mycle_tc
Exit Property
End Get
Set(ByVal Value As String)
mycle_tc = CLE_TC
Exit Property
End Set
End Property

Public Property IDENTIFIANT_TC() As String
Get
IDENTIFIANT_TC = myidentifiant_tc
Exit Property
End Get
Set(ByVal Value As String)
myidentifiant_tc = IDENTIFIANT_TC
Exit Property
End Set
End Property

Public Property MONTANT_TC() As String
Get
MONTANT_TC = mymontant_tc
Exit Property
End Get
Set(ByVal Value As String)
mymontant_tc = MONTANT_TC
Exit Property
End Set
End Property

Public Property DEVISE_TC() As String
Get
DEVISE_TC = mydevise_tc
Exit Property
End Get
Set(ByVal Value As String)
mydevise_tc = DEVISE_TC
Exit Property
End Set
End Property

Public Property REFERENCE_TC() As String
Get
REFERENCE_TC = myreference_tc
Exit Property
End Get
Set(ByVal Value As String)
myreference_tc = REFERENCE_TC
Exit Property
End Set
End Property

Public Property PORTEUR_TC() As String
Get
PORTEUR_TC = myporteur_tc
Exit Property
End Get
Set(ByVal Value As String)
myporteur_tc = PORTEUR_TC
Exit Property
End Set
End Property

Public Property DATEVAL_TC() As String
Get
DATEVAL_TC = mydateval_tc
Exit Property
End Get
Set(ByVal Value As String)
mydateval_tc = DATEVAL_TC
Exit Property
End Set
End Property

Public Property CVV_TC() As String
Get
CVV_TC = mycvv_tc
Exit Property
End Get
Set(ByVal Value As String)
mycvv_tc = CVV_TC
Exit Property
End Set
End Property

Public Property ACTIVITE_TC() As String
Get
ACTIVITE_TC = myactivite_tc
Exit Property
End Get
Set(ByVal Value As String)
myactivite_tc = ACTIVITE_TC
Exit Property
End Set
End Property

Public Property ARCHIVAGE_TC() As String
Get
ARCHIVAGE_TC = myarchivage_tc
Exit Property
End Get
Set(ByVal Value As String)
myarchivage_tc = ARCHIVAGE_TC
Exit Property
End Set
End Property

Public Property NUMAPPEL_TC() As String
Get
NUMAPPEL_TC = mynumappel_tc
Exit Property
End Get
Set(ByVal Value As String)
mynumappel_tc = NUMAPPEL_TC
Exit Property
End Set
End Property

Public Property NUMTRANS_TC() As String
Get
NUMTRANS_TC = mynumtrans_tc
Exit Property
End Get
Set(ByVal Value As String)
mynumtrans_tc = NUMTRANS_TC
Exit Property
End Set
End Property

Public Property AUTORISATION_TC() As String
Get
AUTORISATION_TC = myautorisation_tc
Exit Property
End Get
Set(ByVal Value As String)
myautorisation_tc = AUTORISATION_TC
Exit Property
End Set
End Property

Public Property CODEREPONSE_TC() As String
Get
CODEREPONSE_TC = mycodereponse_tc
Exit Property
End Get
Set(ByVal Value As String)
mycodereponse_tc = CODEREPONSE_TC
Exit Property
End Set
End Property

Public Property COMMENTAIRE_TC() As String
Get
COMMENTAIRE_TC = mycommentaire_tc
Exit Property
End Get
Set(ByVal Value As String)
mycommentaire_tc = COMMENTAIRE_TC
Exit Property
End Set
End Property

Public Property SERVEURIP_TC() As String
Get
SERVEURIP_TC = myserveurip_tc
Exit Property
End Get
Set(ByVal Value As String)
myserveurip_tc = SERVEURIP_TC
Exit Property
End Set
End Property

Public Property SERVEURPORT_TC() As String
Get
SERVEURPORT_TC = myserveurport_tc
Exit Property
End Get
Set(ByVal Value As String)
myserveurport_tc = SERVEURPORT_TC
Exit Property
End Set
End Property

'Public Function Appelppps(ByVal VERSION_TC As Variant, DATEQ_TC As Variant, TYPE_TC As Variant, _
''NUMQUESTION_TC As Variant, SITE_TC As Variant, RANG_TC As Variant, _
''CLE_TC As Variant, IDENTIFIANT_TC As Variant, MONTANT_TC As Variant, _
''DEVISE_TC As Variant, REFERENCE_TC As Variant, PORTEUR_TC As Variant, _
''DATEVAL_TC As Variant, CVV_TC As Variant, ACTIVITE_TC As Variant, _
''ARCHIVAGE_TC As Variant, NUMTRANS_TC As Variant, NUMAPPEL_TC As Variant, _
''SERVEURIP_TC As Variant, SERVEURPORT_TC As Variant, AUTORISATION_TC As Variant, _
''CODEREPONSE_TC As Variant, COMMENTAIRE_TC As Variant) As Integer
Public Function Appelppps() As Object

Dim i As Integer

On Error GoTo err_Renamed

tpPaybox.VERSION_TC = myversion_tc
tpPaybox.DATEQ_TC = mydateq_tc
tpPaybox.TYPE_TC = mytype_tc
tpPaybox.NUMQUESTION_TC = mynumquestion_tc
tpPaybox.SITE_TC = mysite_tc
tpPaybox.RANG_TC = myrang_tc
tpPaybox.CLE_TC = mycle_tc
tpPaybox.IDENTIFIANT_TC = myidentifiant_tc
tpPaybox.MONTANT_TC = mymontant_tc
tpPaybox.DEVISE_TC = mydevise_tc
tpPaybox.REFERENCE_TC = myreference_tc
tpPaybox.PORTEUR_TC = myporteur_tc
tpPaybox.DATEVAL_TC = mydateval_tc
tpPaybox.CVV_TC = mycvv_tc
tpPaybox.ACTIVITE_TC = myactivite_tc
tpPaybox.ARCHIVAGE_TC = myarchivage_tc
tpPaybox.NUMTRANS_TC = mynumtrans_tc
tpPaybox.NUMAPPEL_TC = mynumappel_tc
tpPaybox.SERVEURIP_TC = myserveurip_tc
tpPaybox.SERVEURPORT_TC = myserveurport_tc
tpPaybox.AUTORISATION_TC = myautorisation_tc
tpPaybox.CODEREPONSE_TC = mycodereponse_tc
tpPaybox.COMMENTAIRE_TC = mycommentaire_tc

i = appel_ppps(tpPaybox)

If i = 0 Then
myversion_tc = tpPaybox.VERSION_TC
mydateq_tc = tpPaybox.DATEQ_TC
mytype_tc = tpPaybox.TYPE_TC
mynumquestion_tc = tpPaybox.NUMQUESTION_TC
mysite_tc = tpPaybox.SITE_TC
myrang_tc = tpPaybox.RANG_TC
mycle_tc = tpPaybox.CLE_TC
myidentifiant_tc = tpPaybox.IDENTIFIANT_TC
mymontant_tc = tpPaybox.MONTANT_TC
mydevise_tc = tpPaybox.DEVISE_TC
myreference_tc = tpPaybox.REFERENCE_TC
myporteur_tc = tpPaybox.PORTEUR_TC
mydateval_tc = tpPaybox.DATEVAL_TC
mycvv_tc = tpPaybox.CVV_TC
myactivite_tc = tpPaybox.ACTIVITE_TC
myarchivage_tc = tpPaybox.ARCHIVAGE_TC
mynumtrans_tc = tpPaybox.NUMTRANS_TC
mynumappel_tc = tpPaybox.NUMAPPEL_TC
myserveurip_tc = tpPaybox.SERVEURIP_TC
myserveurport_tc = tpPaybox.SERVEURPORT_TC
myautorisation_tc = tpPaybox.AUTORISATION_TC
mycodereponse_tc = tpPaybox.CODEREPONSE_TC
mycommentaire_tc = tpPaybox.COMMENTAIRE_TC

End If
Appelppps = i
Exit Function

err_Renamed:
Appelppps = -1

End Function
End Class

Apparemment, pour que la dll soit visible, il faut cocher "rendre visible l'assembly par Com" et utiliser regasm au lieu de regsvr32.
Le génération se déroule correctement, mais il semble que mes fonctions et attributs ne soient pas accessibles.
En important la dll dans un nouveau projet, je ne peux pas accéder à la méthode ni aux attributs.
Et le Server.createObject("paybox.appel") ne fonctionne pas non plus
Je sais que quelquechose m'échappe, je suis un novice en la matière, donc si quelqu'un pouvait m'éclairer, ce serait super !

1 réponse

Messages postés
181
Date d'inscription
jeudi 27 février 2003
Statut
Membre
Dernière intervention
2 mars 2009

Bonjour,

j'ai le même problème...
as-tu réussi à trouver la solution ?