Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Calling .net DLL from VFP 9
Message
From
18/04/2007 12:53:51
Alexandre Palma
Harms Software, Inc.
Alverca, Portugal
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01217241
Message ID:
01217373
Views:
22
John you will need to create a class project in VS.NET then you can use the following example, imaging the .net assembly is called vendornet.dll and the namespace is also vendornet, the assembly has n class in this example imagine 1 class is called payments and that class had a getpayment method and a savepayment method.
what I suggest is create in your .net project 1 class file for each class you will use in the vendornet assembly, so let's take the payments class example.
<ComClass(Payments.ClassId, Payments.InterfaceId, Payments.EventsId)> _
Public Class Payments
#Region "COM GUIDs"
    ' These  GUIDs provide the COM identity for this class 
    Public Const ClassId As String = "0815B1E0-ED5D-40e6-B517-D95F55DD5E8A"
    Public Const InterfaceId As String = "058E1672-CA60-4d0b-BAF8-C77E67BC7501"
    Public Const EventsId As String = "15455C40-A39F-48c0-9B27-84F306C56759"
#End Region
    Private Payments as NEW VendorNet.Payments

    Public Function GetPayment(id as integer) as System.Data.DataSet 
        ' or any other type that the vendor.GetPayment would return.
        ' If Getpayment would return an object i.e. payment object you should then create also 
        'that class with same properties and create some method that syncs your payment object 
        'to the vendor net payment object.
        Return Me.Payments.GetPayment(id)
    End Function

End Class
This should be enought for putting you on the right track.

>Can I just connect to the dll and have access to all the methods, etc. or do I need to write code for each one I need to run or access from VFP?
>
>I'm beginning to think it would be easier to write a program in VB and call it with parameters from VFP. I only need to send and retrieve data and most likely only about three or four different sets in each direction.
>
>Thanks again,
>John
>
>>Then as I said you will need to write a .net wrapper and make it com interop.
>>You can start buy doing only the functions that you will need on your app.
>>
>>>Alexandre,
>>>thanks for the info but it did not work. I ran the command and it returned the message: "Types registered successfully" but the dll does not show in intellisense.
>>>
>>>John.
Alexandre Palma
Senior Application Architect
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform