Silverfrost Forums

Welcome to our forums

Jump into C# Constructor from within Fortran

24 Sep 2008 11:30 #3844

I have a question about the OBJECT Method in Fortran. When I use an external Assembly and create an object like in the following code (myBlsDbLibrary)

OBJECT('BLSDBLibrary.BlsDb') myBlsDbLibrary
ASSEMBLY_EXTERNAL(name='BLSDBLibrary.BlsDb.GetData') :: blsdbgetdata
    
OBJECT('System.String') strSQL    
strSQL=NEW@('System.String', 'SCHMELZNR')
! myBlsDbLibrary = new@('BLSDBLibrary.BlsDb')
arraylist=blsdbgetdata(blsdblibrary, strSQL)

I don't jump into the c# constructor! When I debug this code I also doesn't jump into the constructor of the Class BlsDb. Why do I not jump into the contructor?? In this Constructor I connect a Database!

When I'm trying to create an object myBlsDbLibrary with the following code:

OBJECT('BLSDBLibrary.BlsDb') myBlsDbLibrary
myBlsDbLibrary=new@('BLSDBLibrary.BldDb')

I get a compiler error like this: ' There were compile errors, abandoning link...' Can somebody help me to jump in my c# Constructor?

Greeting from Germany

24 Sep 2008 8:55 #3847

The object is only created when you call NEW@ and this is the point where the constructor will be called. If you single step using F11, the debugger will enter the constructor.

However, you post is a little confusing - it seems like you are not able to compile the code? Can you post more details of the error message you are seeing please?

Some things you could check are:

  • have you added a reference to the C# library within the Fortran project?
  • have you used the fully qualified name of the class?
  • if your constructor requires any arguments, have you specified them after the name of the class in the call to NEW@?
25 Sep 2008 4:15 #3848

That is correct: I can't compile the code. The errormessage is: ' There were compile errors, abandoning link...' nothing more!

To your questions: have you added a reference... : YES have you use the qualified name...: YES Like this: 'Namespace.ClassName' I see it within my Intellisense if your constructor requires any...: YES I tried two versions: with Argument and without arguments.

blsdblibrary=NEW@('BLSDBLibrary.BlsDb', 'String')
AND
blsdblibrary=NEW@('BLSDBLibrary.BlsDb')

Every time I get the same Error Message showen above! I use the same Library in an C# Project without any problems! Here's the constructor of the C# Library

namespace BLSDBLibrary
{
public class BlsDb
{
      public BlsDb()
      {
           // Connect to Database
      }
      public BlsDb(String strUser)
     {
          // Connect to Database
     }
....
}
}

Greetings

25 Sep 2008 8:48 #3849

Could you please post your Fortran code as it is very hard to tell what might be causing the problem from the information so far? Thanks.

Please login to reply.