Click here to Skip to main content
15,891,184 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
AnswerRe: Using a forms based GUI as an interface for unmanged C++ code Pin
N a v a n e e t h2-Aug-09 7:13
N a v a n e e t h2-Aug-09 7:13 
GeneralRe: Using a forms based GUI as an interface for unmanged C++ code Pin
alzaeem2-Aug-09 12:13
alzaeem2-Aug-09 12:13 
AnswerRe: Using a forms based GUI as an interface for unmanged C++ code Pin
Adam Maras2-Aug-09 13:23
Adam Maras2-Aug-09 13:23 
GeneralRe: Using a forms based GUI as an interface for unmanged C++ code Pin
N a v a n e e t h2-Aug-09 16:24
N a v a n e e t h2-Aug-09 16:24 
QuestionHow to Parse a string to DATE datatype using Managed C++ Pin
Anitha N.K. Ramesh29-Jul-09 20:26
Anitha N.K. Ramesh29-Jul-09 20:26 
AnswerRe: How to Parse a string to DATE datatype using Managed C++ Pin
teejayem30-Jul-09 3:40
teejayem30-Jul-09 3:40 
GeneralRe: How to Parse a string to DATE datatype using Managed C++ Pin
Anitha N.K. Ramesh3-Aug-09 2:13
Anitha N.K. Ramesh3-Aug-09 2:13 
QuestionPassing multi-dimensional array from C# to Win32 C++ dll [modified] Pin
devvvy29-Jul-09 16:51
devvvy29-Jul-09 16:51 
hello

I'm trying to pass multi-dimensional arrays from C# to un-managed WIN32 C++ dll - second parameter of each of the two functions exported below are meant to be OUTPUT parameter (memory allocated in C# however)
<br />
MATLABGENERICDLL_API void GetCurves(char* strParam, double * myCurve)<br />
{<br />
for(int i=0; i<10; i++)<br />
{<br />
if(i>0) {<br />
myCurve[i] = 1.01 * Curve[i-1];<br />
} else {<br />
myCurve[i] = 0.5;<br />
}<br />
}<br />
return;<br />
}<br />
<br />
MATLABGENERICDLL_API void GetMatrix(char* strParam, double ** myMatrix)<br />
{<br />
try {<br />
for(int i=0; i<10; i++)<br />
{<br />
for(int j=0; j<10; j++)<br />
{<br />
myMatrix[i][j] = 0.25;<br />
}<br />
}<br />
} catch( ...)<br />
{<br />
throw;<br />
}<br />
<br />
return;<br />
}<br />


GetCurves executed successfully, but not GetMatrix.
<br />
class Program<br />
{<br />
[DllImport(@"C:\MatlabGenericDll.dll")]<br />
private static extern string ToUpper2(string Src);<br />
<br />
[DllImport(@"C:\MatlabGenericDll.dll")]<br />
private static extern void GetCurves(string strParam, [In, Out] double[] myCurves);<br />
<br />
[DllImport(@"C:\MatlabGenericDll.dll")]<br />
private static extern void GetMatrix(string strParam, [In, Out] double[,] myMatrix);<br />
<br />
static void Main(string[] args)<br />
{<br />
string strTest = "abc";<br />
string strResult = null;<br />
<br />
double[] myCurve = null;<br />
double[,] myMatrix = null;<br />
<br />
try<br />
{<br />
strResult = ToUpper2(strTest);<br />
<br />
myCurve = new double[100];<br />
GetYieldCurves("AAA", myCurve); << For some reason, executed succssfully (Although I checked &myCurve - address seems to be different in C#/C++ layer so I really don't understand why it worked)<br />
<br />
myMatrix = new double[10, 10];<br />
GetMatrix("BBB", myMatrix); << System.AccessViolationException, complained saying memory probably corrupted.<br />
}<br />
catch (Exception ex)<br />
{<br />
Console.WriteLine(ex.ToString());<br />
}<br />
<br />
return;<br />
}<br />
}<br />


I'm not sure if I am doing right thing ... allocating memory from C# layer and if C# exe and C++ dll share same address space at all.

My end goal is: I actually also need to pass, from c# exe to unmanaged C++ dll, a two-dimensional array of undetermined size of different column types (string, doubles, int, DateTime)

Thanks!

http://msdn.microsoft.com/en-us/library/aa288453(VS.71).aspx

dev

modified on Thursday, July 30, 2009 2:00 AM

AnswerRe: Passing multi-dimensional array from C# to Win32 C++ dll Pin
Luc Pattyn29-Jul-09 21:08
sitebuilderLuc Pattyn29-Jul-09 21:08 
Questiondifficulty coming up with the right format. Pin
Member 315372122-Jul-09 8:56
Member 315372122-Jul-09 8:56 
QuestionRe: difficulty coming up with the right format. Pin
Mark Salsbery23-Jul-09 5:56
Mark Salsbery23-Jul-09 5:56 
AnswerRe: difficulty coming up with the right format. Pin
Member 315372123-Jul-09 7:49
Member 315372123-Jul-09 7:49 
AnswerRe: difficulty coming up with the right format. Pin
amatecki25-Jul-09 9:17
professionalamatecki25-Jul-09 9:17 
QuestionTo write in Status bar Pin
mikobi22-Jul-09 2:45
mikobi22-Jul-09 2:45 
AnswerRe: To write in Status bar Pin
led mike22-Jul-09 4:25
led mike22-Jul-09 4:25 
Questiondepth first search help.. Pin
neha_rai21-Jul-09 10:34
neha_rai21-Jul-09 10:34 
AnswerRe: depth first search help.. Pin
Adam Roderick J23-Jul-09 0:24
Adam Roderick J23-Jul-09 0:24 
QuestionHow to pass a pointer of data to the managed side on a C++ wrapper Pin
sinosoidal19-Jul-09 23:55
sinosoidal19-Jul-09 23:55 
AnswerRe: How to pass a pointer of data to the managed side on a C++ wrapper Pin
N a v a n e e t h20-Jul-09 15:25
N a v a n e e t h20-Jul-09 15:25 
AnswerRe: How to pass a pointer of data to the managed side on a C++ wrapper Pin
amatecki23-Jul-09 8:39
professionalamatecki23-Jul-09 8:39 
QuestionRegarding IWshRuntimeLibrary::IFileSystem Pin
V K 219-Jul-09 22:43
V K 219-Jul-09 22:43 
AnswerRe: Regarding IWshRuntimeLibrary::IFileSystem Pin
lakshman rao13-Jun-20 3:58
lakshman rao13-Jun-20 3:58 
GeneralRe: Regarding IWshRuntimeLibrary::IFileSystem Pin
Richard MacCutchan13-Jun-20 6:28
mveRichard MacCutchan13-Jun-20 6:28 
Questionneed help with "System.Runtime.InteropServices.SEHException" error Pin
UserNameless14-Jul-09 19:36
UserNameless14-Jul-09 19:36 
AnswerRe: need help with "System.Runtime.InteropServices.SEHException" error Pin
Richard Andrew x6414-Jul-09 20:36
professionalRichard Andrew x6414-Jul-09 20:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.