Long story short, a guy at my office wrote a complex routine in C++ which does a lot of calculations with 3D coordinates. Another guy wrote a routine in C# to access the C++ .DLL and return some results. Since VB.NET cannot use UNSAFE, I can't access the C++ .DLL. However, C# can. I'd like to be able to call the C# Class Library from VB.NET but I'm having problems getting C# to return more than one variable.
I've written some simplified code below, but if I can get this to work, then I'll be able to get his code to work.
To start off, I'm not all that familiar with C#, so take it easy on me. This is the C# code I wrote to do the calculation...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace nsClassLibrary
{
public class VBSamples
{
public double RetOneDouble(double GetDouble)
{
double dbl = GetDouble + 11;
return dbl;
}
}
}
In VB.NET, after referencing the C# .DLL, I can use this code to call the C# Class Library to return one variable .
Public Class Form1
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Dim obj As New nsClassLibrary.VBSamples
MessageBox.Show(obj.RetOneDouble(22))
Me.Close()
End Sub
End Class
The problem comes when I pass two or more doubles/variables, C# it handles it fine, but it cannot return both values back to VB.
So I feel like a STRUCT may work for me, I just can't get it to work I'm obviously doing something wrong when setting this up, again, I'm not familiar with C#.
struct struTwoDoubles
{
public double GetDbl1, GetDbl2;
}
But I haven't had any luck with it...
private struTwoDoubles foo(double dbl1, double dbl2)
{
struTwoDoubles abc = new struTwoDoubles();
abc.GetDbl1 = dbl1 * 2;
abc.GetDbl2 = dbl2 * 3;
return (abc.GetDbl1,abc.GetDbl2);
}
I'm not sure what else to try here and I feel I've done a lot of Googling in the last few days, but this isn't addressed much.
Any input will be helpful, thanks in advance.
GAB