Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DllExport class
Message
From
16/11/2016 11:21:16
 
General information
Forum:
ASP.NET
Category:
Other
Title:
Environment versions
Environment:
C# 5.0
OS:
Windows 10
Database:
MS SQL Server
Miscellaneous
Thread ID:
01643554
Message ID:
01643557
Views:
35
This message has been marked as a message which has helped to the initial question of the thread.
>Hi everybody,
>
>I need to create a library project what we should be able to use from VFP project and C# project (and, potentially although unlikely from C++).
>
>There is another solution here by another developer - quite complex for me. I'm trying to use it as a prototype for my project.
>
>That solution consists of many projects. One of them has the following file in the project
>
>
>using System;
>using System.Collections.Generic;
>using System.Text;
>using System.Runtime.CompilerServices;
>using System.Runtime.InteropServices;
>
>namespace DllExport
>{
>    /// <summary>
>    /// Attribute added to a static C# method to export it
>    /// </summary>
>    [AttributeUsage(AttributeTargets.Method)]
>    public class DllExportAttribute : Attribute
>    {
>        private string m_exportName;
>        private CallingConvention m_callingConvention;
>
>        /// <summary>
>        /// Constructor 1
>        /// </summary>
>        /// <param name="exportName"></param>
>        public DllExportAttribute(string exportName)
>            : this(exportName, System.Runtime.InteropServices.CallingConvention.StdCall)
>        {
>        }
>
>        /// <summary>
>        /// Constructor 2
>        /// </summary>
>        /// <param name="exportName"></param>
>        /// <param name="callingConvention"></param>
>        public DllExportAttribute(string exportName, CallingConvention callingConvention)
>        {
>            m_exportName = exportName;
>            m_callingConvention = callingConvention;
>        }
>
>        /// <summary>
>        /// Get the export name, or null to use the method name
>        /// </summary>
>        public string ExportName
>        {
>            get { return m_exportName; }
>        }
>
>        /// <summary>
>        /// Get the calling convention
>        /// </summary>
>        public string CallingConvention
>        {
>            get
>            {
>                switch (m_callingConvention)
>                {
>                    case System.Runtime.InteropServices.CallingConvention.Cdecl:
>                        return typeof(CallConvCdecl).FullName;
>
>                    case System.Runtime.InteropServices.CallingConvention.FastCall:
>                        return typeof(CallConvFastcall).FullName;
>
>                    case System.Runtime.InteropServices.CallingConvention.StdCall:
>                        return typeof(CallConvStdcall).FullName;
>
>                    case System.Runtime.InteropServices.CallingConvention.ThisCall:
>                        return typeof(CallConvThiscall).FullName;
>
>                    case System.Runtime.InteropServices.CallingConvention.Winapi:
>                        return typeof(CallConvStdcall).FullName;
>
>                    default:
>                        return "";
>                }
>            }
>        }
>    }
>}
>
>and the other class in that project uses that attribute this way
>
>
>[DllExport("Test", System.Runtime.InteropServices.CallingConvention.StdCall)]
>        public static String Test(String dataSource, String initialCatalog)
>        {
>            return dataSource + ' ' + initialCatalog;
>        }
>
>that class is static and all methods and properties are static too for that class.
>
>Do I need to follow the same in my new project and add that attribute class as well?

Wouldn't have thought so. Just create a dll, make methods and properties that should be visible to vfp public in the usual way and set the 'Register for Com Interop' flag in the build settings.

>
>The VFP calls are
>
>
>declare integer InitializeConnection in "Siriusware.Fingerprint.Netlink x86.dll" string, string
>					lnInitializeCode = InitializeConnection(.cODBC_DSN, .cDatabase)
>
>Just want to understand if this is needed in my case too?
>
>My class is supposed to use HttpClient class and use its post and get methods to communicate with external API. I found this sample
>
>https://www.dotnetperls.com/httpclient
>
>is it how I generally should do it?

You might have a problem handling async calls if the results are to be consumed by VFP ?.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform