Thanks Oleg. I am going to try a different approach as soon as I clear
my pending tasks (hopefully by the end of the day).

Basically, I'm still going to give Devon's idea another go. Since both
him and Eric already said that J is crashing because it was trying to
unload a non-existent form. We know that loading the profile would
implicitly load a default form.

I'll let you know ASAP.

r/alex
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Oleg Kobchenko
Sent: Thursday, August 14, 2008 2:31 AM
To: Programming forum
Subject: Re: [Jprogramming] J602a Crash after .NET App Quit

Since it was established that loading profile DOES NOT
crash J, it should be possible, by elimination, to narrow 
it down to the code that actually prevents crashing.
With two benefits: allow to ship with only limited
code; may shed light on nature of the problem.



> From: Alex Rufon <[EMAIL PROTECTED]>
> 
> Hi.
> 
> I was wondering if anybody got some headway with this problem of mine.
> 
> I would appreciate any insight on the problem.
> 
> r/alex
> 
> NOTE:
> This is me saying "bump". 
> 
> 
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Alex Rufon
> Sent: Thursday, August 07, 2008 5:14 PM
> To: Programming forum
> Subject: RE: [Jprogramming] J602a Crash after .NET App Quit
> 
> Hello.
> 
> It took some time for me to test since I had to attend a few brain
> numbing meetings today.
> 
> Ok. Here is what I got. I followed Oleg's advice and added the
following
> code to the form:
>         /// 
>         /// Clean up any resources being used.
>         /// 
>         /// true if managed resources should be
> disposed; otherwise, false.
>         protected override void Dispose(bool disposing)
>         {
>             if (disposing && (components != null))
>             {
>                 components.Dispose();
>             }
> 
>             if (jObject != null)
>             {
>                 Marshal.FinalReleaseComObject(jObject);
>                 jObject = null;
>             }
> 
>             base.Dispose(disposing);
>         }
> 
> As what he said, J crashes when this code is executed: 
> Marshal.FinalReleaseComObject(jObject);
> 
> Then I tried out Devon's suggestion and modified the form load to
this:
>         private void Form1_Load(object sender, EventArgs e)
>         {
>             jObject = new JEXEServerLib.JEXEServerClass();
>             jObject.Quit();
>             jObject.Log(1);
> 
>             jObject.Do("11!:0 'pc dummyForm'");
>             jObject.Do("[res=: 'The answer is 42'");
>             object objTest;
>             jObject.GetB("res", out objTest);
>             string jScript = (string)objTest;
>             MessageBox.Show(jScript);
> 
>         }
> 
> Even with the code above, J still crashes. Am I doing this right?
> 
> So I then tried a different approach which is to load the profile:
>         private void Form1_Load(object sender, EventArgs e)
>         {
>             jObject = new JEXEServerLib.JEXEServerClass();
>             jObject.Quit();
>             jObject.Log(1);
> 
>             jObject.Do("BINPATH_z_=: 1!:46 ''");
>             jObject.Do("ARGV_z_=: ,<'oleclient'");
>             jObject.Do("0!:0 
>             jObject.Show(1);
>             object objTest;
>             jObject.GetB("BINPATH", out objTest);
>             string jScript = (string)objTest;
>             MessageBox.Show(jScript);
>         }
> 
> This one DOES NOT crash but defeats the purpose of only distributing
> J.EXE and J.DLL with the IJS script since it requires a full install
of
> J.
> 
> I would appreciate any help or suggestions. 
> 
> Thanks.
> 
> r/alex
> 
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Oleg Kobchenko
> Sent: Thursday, August 07, 2008 1:55 AM
> To: Programming forum
> Subject: Re: [Jprogramming] J602a Crash after .NET App Quit
> 
> >From what I can see, in the end you do
> 
> >             jObject = null;
> 
> which causes object destruction on the GC thread,
> but it was created on the main thread. This may be disastrous.
> 
> To avoid this, you need to release COM object explicitly
> (google it):
> 
>         #region IDisposable Members
> 
>         public void Dispose() {
>             if (_comobj != null) {
>                 Marshal.FinalReleaseComObject(_comobj);
>                 GC.SuppressFinalize(_comobj);
>                 _comobj = null;
>             } else {
>                 // MyTrace.Write("Disposing uninitialized object.");
>             }
>         }
> 
> (Also, shouldn't it be FormClosed event?)
> 
> However, this does not fix the error, only to track it easily.
> It allows to place the breakpoint and see that the crash 
> happens in release:
> 
>     Marshal.FinalReleaseComObject(_comobj);
> 
> Switching back to j601 does not reproduce the error.
> 
> wd 'pc f;...pshow...' does not help.
> 
> Crash details:
> 
> Unhandled exception at 0x7c915375 (ntdll.dll) in j.exe: 0xC0000005:
> Access violation reading location 0x00e3000c.
> 
> >    ntdll.dll!bsearch()  + 0x1a2 bytes    
>      [Frames below may be incorrect and/or missing, no symbols loaded
> for ntdll.dll]    
>      ntdll.dll!bsearch()  + 0x157 bytes    
>      ntdll.dll!bsearch()  + 0xba bytes    
>      ntdll.dll!RtlFindActivationContextSectionString()  + 0x80 bytes

>      ntdll.dll!RtlDosApplyFileIsolationRedirection_Ustr()  + 0x34e
bytes
> 
>      ntdll.dll!RtlDosApplyFileIsolationRedirection_Ustr()  + 0x20f
bytes
> 
>      ntdll.dll!LdrGetDllHandleEx()  + 0xa7 bytes    
>      ntdll.dll!LdrGetDllHandle()  + 0x18 bytes    
>      kernel32.dll!GetModuleHandleW()  + 0x57 bytes    
>      kernel32.dll!GetModuleHandleW()  + 0x16e bytes    
>      kernel32.dll!GetModuleHandleW()  + 0x1f bytes    
>      kernel32.dll!GetModuleHandleA()  + 0x1f bytes    
>      j.exe!00453a98()    
>      j.exe!00453abc()    
>      j.exe!00453ce1()    
>      j.exe!00453d06()    
>      j.exe!00418073()    
>      j.exe!004189fc()    
>      j.exe!00430f54()    
>      ole32.dll!DcomChannelSetHResult()  + 0x190 bytes    
>      ole32.dll!77600b36()    
>      ole32.dll!77600b43()    
>      j.exe!0042d0a4()    
>      j.exe!0042f5b7()    
>      j.exe!0043f767()    
>      j.exe!0042a882()    
>      j.exe!00435a6a()    
>      j.exe!0042f644()    
>      user32.dll!GetDC()  + 0x6d bytes    
>      user32.dll!GetDC()  + 0x14f bytes    
>      user32.dll!GetWindowLongW()  + 0x127 bytes    
>      user32.dll!DispatchMessageW()  + 0xf bytes    
>      j.exe!00418230()    
>      j.exe!00417c54()    
>      j.exe!0046756e()    
>      j.exe!0045143d()    
>      kernel32.dll!RegisterWaitForInputIdle()  + 0x49 bytes    
> 
> 
> > From: Alex Rufon 
> > 
> > I'm currently in the process of migrating to J602a (again) and I hit
a
> > brick wall. J would crash right after the calling .NET application
> > exits. 
> > 
> > First off, I'm using the following softwares:
> > 1. Vista Ultimate
> > 2. C# on Visual Studio .NET 2005 Professional Edition
> > 
> > Since I know that not everyone has my version of Visual Studio .NET,
I
> > replicated the problem using the FREE Visual Studio .NET 2008
Express
> > Edition. You can download a copy from here:
> > http://www.microsoft.com/express/default.aspx
> > 
> > So follow these steps to replicate the crash:
> > 1. Run Microsoft Visual C# 2008 Express Edition
> > 2. Create a new Windows Application project. The automatically
created
> > project should have a form named form1
> > 3. Add a reference to J602\bin\j.exe 
> > 4. Add a button to form1
> > 5. Add the following code into form1:
> > 
> > using System;
> > using System.Collections.Generic;
> > using System.ComponentModel;
> > using System.Data;
> > using System.Drawing;
> > using System.Linq;
> > using System.Text;
> > using System.Windows.Forms;
> > 
> > namespace WindowsFormsApplication1
> > {
> >     public partial class Form1 : Form
> >     {
> >         private JEXEServerLib.JEXEServerClass jObject;
> >         public Form1()
> >         {
> >             InitializeComponent();
> >         }
> > 
> >         private void Form1_Load(object sender, EventArgs e)
> >         {
> >             jObject = new JEXEServerLib.JEXEServerClass();
> >             jObject.Quit();
> >         }
> > 
> >         private void button1_Click(object sender, EventArgs e)
> >         {
> >             jObject.Do("[res=: i. 1024 1024");
> >         }
> > 
> >         private void Form1_FormClosing(object sender,
> > FormClosingEventArgs e)
> >         {
> >             jObject = null;
> >         }
> >     }
> > 
> > }
> > 
> > As you can see from the code above. This project will do nothing but
> > create an instance of J when it loads. A button that would just make
a
> > 1024x1024 matrix inside the J instance and then set the jObject
> variable
> > to nothing when it closes.
> > 
> > The problem is that after this application closes, J will crash
> > spectacularly. :)
> > 
> > I have tested this in VB.NET and C# in both Visual Studio .NET 2005
> > Professional and 2008 Express edition.
> > 
> > I am hoping that I am just missing a step somewhere. Like maybe I
need
> > to call a "release" manually? Any insight would be helpful. 
> > 
> > Thanks.
> > 
> > r/alex
> >
----------------------------------------------------------------------
> > For information about J forums see
http://www.jsoftware.com/forums.htm
> 
> 
> 
>       
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm



      
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to