G
Guest
I've written a dll in managed C++ and created a reference to the FincadFunction
class from a VB.NET application. I'm calling the methods in my VB.NET app b
creating a reference to the dll and then an object variable for the FincadFunctions class
I'm unable to get the value for return_days or return_RtnStat_MC after th
function call. Is there a way to specify in MC++ that the argument shoul
be passed by reference? (ByRef? out? MarshalAs?
Any ideas on how to return the values to VB.NET thru the last argument
Below is the code from my MC++ dll
#using <mscorlib.dll
#include "fcvbdotnet.h
#include "vbdotnetut.h
#include "mt.h
public __gc class FincadFunction
public
int aaTest() { return(NORMAL); }
int aaAccrual_days (double d_e, double d_t, int acc, double return_days
int status = 0
LPXLOPER resultptr = NULL
// convert objects and optional values, if an
// call dl
resultptr = aaAcc_Days_dll(d_e, d_t, acc)
// extract the returning result
status = ExtractValue(resultptr, &return_days)
if (status != NORMAL)
aaGlobalFreeAllA()
GlobalFreeAllMem()
return(ABEND)
// free resources used by input object
aaGlobalFreeAllA()
GlobalFreeAllMem()
// return to caller as successfu
return(NORMAL)
int aaAver_strk_basket_fs_MC ( double ast_info __gc[,], double corr_matrix __gc[,],
double d_v, double d_exp, double d_aver, double rate_ann,
double sam_seq __gc[,], int option_type, double num_rnd,
int table_type, double return_RtnStat_MC __gc[,]
int status = 0
LPXLOPER resultptr = NULL
LPXLOPER ast_info_ptr = NULL
LPXLOPER corr_matrix_ptr = NULL
LPXLOPER sam_seq_ptr = NULL
// convert objects and optional values, if an
status = ConvertObjectDouble(ast_info, &ast_info_ptr)
if (status != NORMAL)
aaGlobalFreeAllA()
GlobalFreeAllMem()
return(ABEND)
status = ConvertObjectDouble(corr_matrix, &corr_matrix_ptr)
if (status != NORMAL)
aaGlobalFreeAllA()
GlobalFreeAllMem()
return(ABEND)
status = ConvertObjectDouble(sam_seq, &sam_seq_ptr)
if (status != NORMAL)
aaGlobalFreeAllA()
GlobalFreeAllMem()
return(ABEND)
// call dl
resultptr = aver_strk_basket_fs_MC_dll(ast_info_ptr, corr_matrix_ptr, d_v, d_exp, d_aver, rate_ann, sam_seq_ptr, option_type,
num_rnd, table_type)
// extract the returning result
status = ExtractObject(resultptr, return_RtnStat_MC)
if (status != NORMAL)
aaGlobalFreeAllA()
GlobalFreeAllMem()
return(ABEND)
// free resources used by input object
aaGlobalFreeAllA()
GlobalFreeAllMem()
// return to caller as successfu
return(NORMAL)
}
class from a VB.NET application. I'm calling the methods in my VB.NET app b
creating a reference to the dll and then an object variable for the FincadFunctions class
I'm unable to get the value for return_days or return_RtnStat_MC after th
function call. Is there a way to specify in MC++ that the argument shoul
be passed by reference? (ByRef? out? MarshalAs?
Any ideas on how to return the values to VB.NET thru the last argument
Below is the code from my MC++ dll
#using <mscorlib.dll
#include "fcvbdotnet.h
#include "vbdotnetut.h
#include "mt.h
public __gc class FincadFunction
public
int aaTest() { return(NORMAL); }
int aaAccrual_days (double d_e, double d_t, int acc, double return_days
int status = 0
LPXLOPER resultptr = NULL
// convert objects and optional values, if an
// call dl
resultptr = aaAcc_Days_dll(d_e, d_t, acc)
// extract the returning result
status = ExtractValue(resultptr, &return_days)
if (status != NORMAL)
aaGlobalFreeAllA()
GlobalFreeAllMem()
return(ABEND)
// free resources used by input object
aaGlobalFreeAllA()
GlobalFreeAllMem()
// return to caller as successfu
return(NORMAL)
int aaAver_strk_basket_fs_MC ( double ast_info __gc[,], double corr_matrix __gc[,],
double d_v, double d_exp, double d_aver, double rate_ann,
double sam_seq __gc[,], int option_type, double num_rnd,
int table_type, double return_RtnStat_MC __gc[,]
int status = 0
LPXLOPER resultptr = NULL
LPXLOPER ast_info_ptr = NULL
LPXLOPER corr_matrix_ptr = NULL
LPXLOPER sam_seq_ptr = NULL
// convert objects and optional values, if an
status = ConvertObjectDouble(ast_info, &ast_info_ptr)
if (status != NORMAL)
aaGlobalFreeAllA()
GlobalFreeAllMem()
return(ABEND)
status = ConvertObjectDouble(corr_matrix, &corr_matrix_ptr)
if (status != NORMAL)
aaGlobalFreeAllA()
GlobalFreeAllMem()
return(ABEND)
status = ConvertObjectDouble(sam_seq, &sam_seq_ptr)
if (status != NORMAL)
aaGlobalFreeAllA()
GlobalFreeAllMem()
return(ABEND)
// call dl
resultptr = aver_strk_basket_fs_MC_dll(ast_info_ptr, corr_matrix_ptr, d_v, d_exp, d_aver, rate_ann, sam_seq_ptr, option_type,
num_rnd, table_type)
// extract the returning result
status = ExtractObject(resultptr, return_RtnStat_MC)
if (status != NORMAL)
aaGlobalFreeAllA()
GlobalFreeAllMem()
return(ABEND)
// free resources used by input object
aaGlobalFreeAllA()
GlobalFreeAllMem()
// return to caller as successfu
return(NORMAL)
}