You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's hard to tell how marshalling is going without debugging in your case when you're trying to refer it as an actual clr type.
For this case or such I recommend to use IntPtr because it exactly allows you to fully control the process step by step.
In your VBA script you can change the Declare signature to LongPtr same like I suggested here #189 (comment)
Note also you don't need unsafe context.
For IntPtr control your structure either through PtrToStructure() or use Conari like:
Hello.
I need pass UDT from VBA to c# dllexport function. But not show anything.
C# side:
[code]
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace ClassLibrary1
{
public unsafe class Class1
{
[DllExport(CallingConvention.StdCall)]
public static void test(ref Record rec)
{
}
[/code]
Excel VBA side (bas module):
`Type Record2
Name As String
Value As String
End Type
Private Declare PtrSafe Sub test Lib "C:\mypath\ClassLibrary1.dll" (ByRef rec2 As Record2)
Sub deneme()
Dim r As Record2
End Sub`
The text was updated successfully, but these errors were encountered: