Hey,
I am working on my master thesis and need your help! Btw I am studying mechanical enginneering... so my programming skills are limited.
Here my problem:
I have a DLL, which is created in C# ( I cannot post it, because it is a part of an unpublished research). But it gives me some Arrays ( 1D-Array [], 2DArray[,] ).
For a simulation with ABAQUS I need to import that C#-DLL in C++ and/or FORTRAN.
I found the solution from Robert Giesecke to create a unmanaged DLL. I think this is the easiest solution for me. (Of course if someone has another solution for me, a wrapper or something, please post it)
Here my 1D Array example for a unmanaged C#-DLL created with R.Giesecke Template:
using System;
using System.Text;
using RGiesecke.DllExport;
using System.Runtime.InteropServices;
namespace Testme
{
class Test
{
[DllExport("Get1DArray", CallingConvention = CallingConvention.StdCall)]
public static double Get1DArray([MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] double[] STRESS, int i)
{
return STRESS[i];
}
}
}
and here my 2D Array code:
using System;
using System.Text;
using RGiesecke.DllExport;
using System.Runtime.InteropServices;
namespace Testme
{
class Test
{
public static int idx(int a, int b) { int cols = 2; return a * cols + b; }
[DllExport("Set2DArray", CallingConvention = CallingConvention.StdCall)]
public static int Set2DArray([In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] int[] STRAIN, int len)
{
STRAIN[idx(0, 0)] = 0;
STRAIN[idx(0, 1)] = 1;
STRAIN[idx(1, 0)] = 2;
STRAIN[idx(1, 1)] = 3;
STRAIN[idx(2, 0)] = 4;
STRAIN[idx(2, 1)] = 5;
return 0;
}
}
}
The Build have succeeded at both. How can I import the DLLs in C++ and/or FORTRAN?
Thx in advance!