C# call Gauss Procedure failed.(Version: Gauss 10)

Hi experts,

In my project, all of our data are dealt with C#.  So, i built the process of calling Gauss procedure with C++ into a dll, and this dll will be called by C#.  Now, i got a problem. When using C++ to call my Gauss Procedure with C APIs, there is no problem when executing. But if building the same code with C++ into a dll, using C# to call this dll, the GAUSS_Execute() will return a 493 error.

(I create 2 solutions in Visual Studio, one is CLR dll library which call Gauss Code with C++, and other is C# solution to call the CLR dll.)

The Gauss code:

format /m1 /rd 8,4;
declare inflnm, flnm;

FF=xlsreadm(inflnm, "", 1, "");
erow=rows(FF); brow=erow-500+1;
{DD,ID} = selectItem(FF[1,.]|FF[brow:erow,.]);

dt=DD[.,1];
YY=ln(DD[.,cols(DD)-1]);
XX=ln(DD[.,2:cols(DD)-2]);
Rt=XX-YY;

ret=xlsWrite(Rt,flnm,"A2",1,"");

 

proc(2) = selectItem(FF);
local i,j,n,m,dd,id,flag;

   dd=FF[.,1];
   n=rows(FF); m=cols(FF);
   for j (2,m,1);
      flag=0;
      for i (1,n,1);
         if FF[i,j]==-99 or FF[i,j]==-1;
            flag=1;
            break;
         endif;
      endfor;
      if flag==0;
         dd=dd~FF[.,j];
      endif;
   endfor;

retp(dd[2:n,.],dd[1,2:cols(dd)]);
endp;

 

Thanks a lot.

 

 

2 Answers



0



Colin,

Additional error information for compiling/running programs can be obtained by setting a hook to a custom defined function in C++. In your case, you're going to need to store this information in a way that can be referenced by C#. A second file logging example is also presented if you wish to go that route.

Example:

// This can also be a static class method.
void internalHookError(char *output) {
    // output contains error information from the engine
    // store this in a variable retrievable by C#
}

// This must be ran repeatedly if a new thread is created
// when calling GAUSS_Execute.
GAUSS_HookProgramErrorOutput(internalHookError);

With the above code in place, all error information will be routed to the assigned function pointer.

If logging to a file for diagnostics is more desirable, this can easily be achieved:

// 'a' is for appending to existing file. 
// 'w' can be used to overwrite an existing file
GAUSS_SetLogFile("filename", "a"); 

Aptech has, for the purpose of multi-language integration with the GAUSS Engine, already created a C++ wrapper.

You may find some helpful information in this repository. The C++ specific code is located at:

https://github.com/aptech/gsoop/tree/master/src

Please let us know if we can be of further assistance.

aptech

1,773


0



Thank you for your help, let me have an investigation firstly.

Your Answer

2 Answers

0

Colin,

Additional error information for compiling/running programs can be obtained by setting a hook to a custom defined function in C++. In your case, you're going to need to store this information in a way that can be referenced by C#. A second file logging example is also presented if you wish to go that route.

Example:

// This can also be a static class method.
void internalHookError(char *output) {
    // output contains error information from the engine
    // store this in a variable retrievable by C#
}

// This must be ran repeatedly if a new thread is created
// when calling GAUSS_Execute.
GAUSS_HookProgramErrorOutput(internalHookError);

With the above code in place, all error information will be routed to the assigned function pointer.

If logging to a file for diagnostics is more desirable, this can easily be achieved:

// 'a' is for appending to existing file. 
// 'w' can be used to overwrite an existing file
GAUSS_SetLogFile("filename", "a"); 

Aptech has, for the purpose of multi-language integration with the GAUSS Engine, already created a C++ wrapper.

You may find some helpful information in this repository. The C++ specific code is located at:

https://github.com/aptech/gsoop/tree/master/src

Please let us know if we can be of further assistance.

0

Thank you for your help, let me have an investigation firstly.


You must login to post answers.

Have a Specific Question?

Get a real answer from a real person

Need Support?

Get help from our friendly experts.