forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

ClearWin+/.NET callback crash

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+
View previous topic :: View next topic  
Author Message
Sebastian



Joined: 20 Feb 2008
Posts: 177

PostPosted: Thu Feb 05, 2009 4:20 pm    Post subject: ClearWin+/.NET callback crash Reply with quote

Hello,

trying to combine a ClearWin+ application, which uses a callback on a Quit button, with some interface to a .NET library. Both things are unrelated at the moment, that is the call to a .NET routine is separate from the ClearWin+ code.

In general it works fine, the .NET subroutine is called, and the ClearWin+ window is created. If the .NET subroutine contains more complex memory operations, or, which is relevant, a plain call to the garbage collector, the ClearWin+ callback ceases to work. The errormessage translates to something like "CallbackOnCollectDelegate was found" which seems to indicate that the garbage collector removed (?) the callback function, and ftn95lib.mdl!Salford.Fortran.RTLibrary+clearwin_callback::Invoke fails.


Some steps to reproduce this:
Quote:
Create new Project, FTN95 Application
Add another project: File, Add, New Project
Choose C# Class Library for example
In the project settings assure that the FortranApplication is the start project.
Also make the ClassLibrary project a dependency of the FortranApplication

Add the ClassLibrary to the References of the FortranApplication.


Code for the fortran part:
Code:
INTEGER FUNCTION cb_quit()
    IMPLICIT NONE
    cb_quit = 0
END FUNCTION

PROGRAM Main
    IMPLICIT NONE
    EXTERNAL cb_quit
    INTEGER cb_quit, iw

    ASSEMBLY_EXTERNAL(NAME="ClassLibrary1.Class1.class_test_routine")      &
                      class_test_routine
    OBJECT("ClassLibrary1.Class1") CLASS1
    CLASS1 = NEW@("ClassLibrary1.Class1")
    CALL class_test_routine(CLASS1)
    iw = winio@('%^bt[&Quit]', cb_quit)
END


Code for the c# part:
Code:
using System;
using System.Collections.Generic;
using System.Text;

namespace ClassLibrary1
{
    public class Class1
    {
        public void class_test_routine()
        {
//            GC.Collect();
            const int max_lp = 100;

            int[][] test = new int[max_lp][];
            for (int ct = 0; ct < max_lp; ct++)
            {
                test[ct] = new int[65536];
            }
        }

    }
}


The error might or might not occur with the int[] allocation as above, it seems to depend on the garbage collector's properties (memory size?), but forcing the collector to run via GC.Collect() always results in the bug.

I've already tried quite a lot of things, like encapsulating the ClearWin+ code in a module, but couldn't get it working. Any help or hints appreciated.

Thanks.
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Thu Feb 05, 2009 5:19 pm    Post subject: Reply with quote

Have you read the KBase article in this Forum called "Using ClearWin+ under .NET"?
Back to top
View user's profile Send private message AIM Address
Sebastian



Joined: 20 Feb 2008
Posts: 177

PostPosted: Fri Feb 06, 2009 8:20 am    Post subject: Reply with quote

Quote:
Have you read the KBase article in this Forum called "Using ClearWin+ under .NET"?

Yes I'm aware of that article yet fail to see how it'd be helpful in this case.


Besides that, when using the code posted in the article, along with a reference to another project ( /REF to a C# class library for example) the compilation fails with an internal linker error (or with an exception violation in 0048ea78: collect_fortran_symbols(<ptr>struct scope) [+0231] if there's code that creates an object). Both issues vanish if the include <windows.ins> is not specified.

Thanks.
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Fri Feb 06, 2009 8:46 pm    Post subject: Reply with quote

The main point is that we are only beginning to provide some support for ClearWin+ under .NET. Anything you get at the moment is a free bonus because ClearWin+ was not expected to work under .NET and Visual ClearWin was designed to replace it.

I will not be able to respond to your query for a little while. In the meantime one of our users may be able to help.
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+ All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group