I'm not able to pass the 4th parameter correctly. If I make the DLL
an Application, with the simulation model passed in the command line,
the same function call to Esa_Init() works correctly.
The argc and argv are the standard command line parameter count and
parameter array values. The esaHandle is an "opaque" reference--I
understand that it allows provides a handle to the simulation to be
passed to other functions called within OPNET ESA API.
So... If this is a threading issue (AccessViolationException) then
how do I make the call in a thread-safe manner?
DOCUMENTATION:
Esa_Init (argc, argv, options, esa_state_pptr)
Argument Type Description
argc int size of argv array
argv char ** array of strings, typically as
provided to the main() entry point
options int one of:
ESAC_INIT_OPTS_TRACE-trace all subsequent ESA calls (similar to the
tracing of kernel procedures in ODB)
ESAC_INIT_OPTS_DEBUG-run the simulation with the ODB interface
ESAC_OPTS_NONE-no special options
esa_state_pptr EsaT_State_Handle * will be filled with an ESA
opaque data structure used by the other ESA APIs.
Return Type
EsaT_Compcode -- EsaC_Comp_Success if initialization succeeds;
EsaC_Comp_Failure otherwise.
Details
This function performs the main initialization of the ESA library. It
sets up the OPNET analysis software environment based on the argument
list, loads preference files (env_db, .ef), and so on.
On Jun 14, 4:00 pm, "Bruno van Dooren [MVP - VC++]"
<bruno_nos_pam_van_doo...@hotmail.com> wrote:
> > I'm requesting assistance from some of you smart folks out there to
> > get the managed calls write that meet the specification in the esa.h
> > for Esa_Init. When I make a call, VS2005 reports
> > "AccessViolationException" and refers to the 4th parameter
> > (EsaT_State_Handle). I don't know how to define nor pass this
> > reference correctly to the legacy DLL. What am I doing wrong? Thanks
> > in advance!!
>
> What does the documentation for that function say?
> Are you passing the correct values?
> An access violation means that that function is reading or writing in a
> place that it has no access to. Probebly due to bad pointer values.
>
>
>
>
>
> > esa.h
> > **********************************
> > #define SIM_EXPORT DLLIMPORT
>
> > typedef struct EsaT_State EsaT_State;
> > typedef EsaT_State * EsaT_State_Handle;
>
> > typedef enum EsaT_Compcode
> > {
> > EsaC_Comp_Failure,
> > EsaC_Comp_Success
> > } EsaT_Compcode;
>
> > DLLIMPORT EsaT_Compcode Esa_Init (int argc, char *argv[], int options,
> > EsaT_State_Handle * esa_state_pptr);
> > ************************************
>
> > CPP Wrapper in DLL:
> > ****************************
> > #include "stdafx.h" //Includes esa.h above
>
> > //Globals
> > EsaT_State_Handle esaHandle;
>
> > extern "C" __declspec(dllexport) int __stdcall main(int argc, char*
> > argv[])
> > {
> > Esa_Init(argc, argv, ESAC_OPTS_NONE, &esaHandle);
> > return 0;
> > }
> > *****************************
>
> Why do you export main here?
> main is the entry point of your application.
> What does Esa_init expect in argc and argv?
> Does esaHandle need to be a valid pointer value?
>
> --
> Kind regards,
> Bruno van Dooren MVP - VC++
> http://msmvps.com/blogs/vanDooren
> bruno_nos_pam_van_doo...@hotmail.com- Hide quoted text -
>
> - Show quoted text -