Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DllExport and passing parameters by reference
Message
From
30/11/2016 05:31:09
 
General information
Forum:
ASP.NET
Category:
Troubleshooting
Environment versions
Environment:
C# 5.0
OS:
Windows 10
Database:
MS SQL Server
Miscellaneous
Thread ID:
01644109
Message ID:
01644128
Views:
20
>>>Hi everybody,
>>>
>>>I am wondering if anyone of you has experience making C# dll to be accessible from VFP using DllExport utility. In particular, I am interested in passing parameters by reference.
>>>
>>>I made a simple function in C#
>>>
>>>
>>>[DllExport("CheckParamsByRef", System.Runtime.InteropServices.CallingConvention.StdCall)]
>>>        /// <summary>
>>>        /// CheckParamsByRef
>>>        /// <param name="test">The string to return by reference</param>
>>>        public static int CheckParamsByRef(ref String test)
>>>        {
>>>            test = "Hello from C#";
>>>            return 1;
>>>        }
>>>
>>>
>>>and try to call it from VFP
>>>
>>>
>>>DECLARE integer CheckParamsByRef IN "MyDLL x86.dll" ;
>>>    string @ 
>>>ReturnValueText = ""
>>>    ? CheckParamsByRef(@ReturnValueText)
>>>    ? 'ReturnValueText: ' + ReturnValueText
>>>
>>>On the ? CheckParamsByRef call I'm getting exception from DLL.
>>>
>>>Does it mean we can not use DllExport and passing parameters by reference? Is there any way around the problem?
>>>
>>>Thanks in advance.
>>
>>Why bother exporting? AFAIR you can use standard interop and get the DLL by using CreateObject() in VFP
>
>I tried exporting because this project already using another dll and uses DECLARE for its functions.
>
>But since this seems to be a dead end, I need to re-group.
>
>I was trying to use wwDotNetBridge but also was getting some problems. Also, although we do use bridge in another project already, this one was not using it.
>
>Do you suggest to just make by dll com-visible?

Yes - unless you want finer control over what is visible. If you do then apply the relevant attributes - see : https://msdn.microsoft.com/en-us/library/7fcfby2t.aspx

>What else is involved and how simple it's to distribute that new dll (would I need to do anything else)?

Guess you will need the relevant .NET framework (or at least those on which the DLL has a dependency)
Previous
Reply
Map
View

Click here to load this message in the networking platform