Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Calling C++ dll from C# - how to debug?
Message
Information générale
Forum:
C#
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01655067
Message ID:
01655090
Vues:
73
You can't call a DLL function that returns a string because there's no way for FoxPro - at least not without an FLL in between - to capture the pointer that the function returns. CDecl calling convention generally doesn't work - you can only really call DLLs with WINAPI calling convention which has all APIs pretty much returning numeric values and any 'real' return values returned in passed in buffers.

Your best bet is to wrap the function in a .NET DLL and call it with wwDotnetBridge or plain COM interop.

+++ Rick ---

>Hi everybody,
>
>This is how the function is declared in C# (see VFP declaration in a comment - it works fine from VFP):
>
>
> //declare string Invoke1 in (addbs(justpath(.cProgramPath)) + "ww_local.dll") as ww_localInvoke string cInvokeString
>
>        [DllImport(@"C:\Program Files (x86)\Siriusware\Pool\ww_local.dll", 
>            ExactSpelling = false, 
>            CallingConvention = CallingConvention.Cdecl, 
>            CharSet = CharSet.Auto)]
>        static extern String Invoke1([MarshalAs(UnmanagedType.LPTStr)] String str);
>
>And then in the C# code I try to do
>
>
> translate = Invoke1(invoke);
>
>and then the C# test stops and I see a dmp file generated.
>
>If I try to open that file in VS 2015 and debug in mixed mode I get
>
>Unhandled exception at 0x777F9D71 (ntdll.dll) in vstest.executionengine.x86.exe.13284.dmp: 0xC0000374: A heap has been corrupted (parameters: 0x7782D8D0).
>
>What can I do to figure out what may be a problem and why it works from VFP but not C#?
>
>Thanks a lot in advance.
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform