Re: GCHandle exception (appdomain related?) (was: Re: [Partly-SOLVED!] Re: Output from Console.WriteLine methods is deferred)

"Charlie Poole" <[email protected]> Sun, 20 Jul 2008 14:02:34 -0700
Newsgroups gmane.comp.windows.dotnet.nunit.user
Message-ID <005401c8eaab$f00202f0$6401a8c0@ferrari>
Hi Andres, 

The documentation for domain= is buried on this page:
http://nunit.org/?p=consoleCommandLine&r=2.4.7

I've recently had several questions about domain=None,
leading me to realize that something like the following 
should be in the docs.

Domain=none is a hack that most people should never
use. It was created for one user, with code that could
not even execute correctly in a secondary AppDomain.
Since there is only one domain, there is only one 
application base and config file. To use it, you must
copy the NUnit itself to the directory containing your
test assembly. Any entries you would normally put in
a test config file must go in the nunit config.

Unfortunately, because there is no such text, lots of 
people try it as soon as they have a problem with
AppDomains. Our bad.

Do you have any indication of where the exception
is being thrown?

Charlie

> -----Original Message-----
> From: [email protected] 
> [mailto:[email protected]] On Behalf 
> Of "Andrés G. Aragoneses"
> Sent: Sunday, July 20, 2008 1:12 PM
> To: [email protected]
> Subject: [Nunit-users] GCHandle exception (appdomain 
> related?) (was: Re: [Partly-SOLVED!] Re: Output from 
> Console.WriteLine methods is deferred)
> 
> 
> Sorry for writing without further investigation! I've come to 
> know about the -domain=X option but:
> 
> - When using domain=none I get this error:
> Could not load file or assembly 'GailTest' or one of its 
> dependencies. 
> The system cannot find the file specified.
> 
> - When using domain=single I get this exception (which seems 
> to be the same as the one noted in my previous email):
> 
> Exception in Gtk# callback delegate
>    Note: Applications can use GLib.ExceptionManager.UnhandledException
> to handle the exception.
> System.ArgumentException: GCHandle value belongs to a different domain
>    at System.Runtime.InteropServices.GCHandle.op_Explicit 
> (IntPtr value) [0x00000]
>    at GLib.Signal.voidObjectCallback (IntPtr handle, IntPtr 
> data) [0x00000]
>     at 
> GLib.ExceptionManager.RaiseUnhandledException(System.Exception
>  e, Boolean is_terminal)
>     at GLib.Signal.voidObjectCallback(IntPtr handle, IntPtr data)
>     at GLib.Signal.voidObjectCallback(IntPtr , IntPtr )
>     at Gtk.Object.gtk_object_destroy(IntPtr )
>     at Gtk.Object.gtk_object_destroy(IntPtr )
>     at Gtk.Object.Destroy()
>     at Gtk.Widget.Destroy()
>     at GailTestApp.MainClass.Kill()
>     at UiaAtkBridgeTest.GailTester.End()
>     at 
> System.Reflection.MonoMethod.InternalInvoke(System.Object , 
> System.Object[] )
>     at 
> System.Reflection.MonoMethod.InternalInvoke(System.Object , 
> System.Object[] )
>     at System.Reflection.MonoMethod.Invoke(System.Object obj, 
> BindingFlags invokeAttr, System.Reflection.Binder binder, 
> System.Object[] parameters, System.Globalization.CultureInfo culture)
>     at System.Reflection.MethodBase.Invoke(System.Object obj, 
> System.Object[] parameters)
>     at NUnit.Core.Reflect.InvokeMethod(System.Reflection.MethodInfo
> method, System.Object fixture, System.Object[] args)
>     at NUnit.Core.Reflect.InvokeMethod(System.Reflection.MethodInfo
> method, System.Object fixture)
>     at NUnit.Core.TestSuite.DoOneTimeTearDown(NUnit.Core.TestResult
> suiteResult)
>     at
> NUnit.Core.NUnitTestFixture.DoOneTimeTearDown(NUnit.Core.TestResult
> suiteResult)
>     at NUnit.Core.TestSuite.Run(EventListener listener, 
> ITestFilter filter)
>     at NUnit.Core.TestFixture.Run(EventListener listener, ITestFilter
> filter)
>     at NUnit.Core.TestSuite.RunAllTests(NUnit.Core.TestSuiteResult
> suiteResult, EventListener listener, ITestFilter filter)
>     at NUnit.Core.TestSuite.Run(EventListener listener, 
> ITestFilter filter)
>     at NUnit.Core.TestSuite.RunAllTests(NUnit.Core.TestSuiteResult
> suiteResult, EventListener listener, ITestFilter filter)
>     at NUnit.Core.TestSuite.Run(EventListener listener, 
> ITestFilter filter)
>     at NUnit.Core.SimpleTestRunner.Run(EventListener 
> listener, ITestFilter filter)
>     at NUnit.Core.TestRunnerThread.TestRunnerThreadProc()
> 
> 
> And it's not very clear what options are available for the 
> -domain=X option. BTW, then, when has this appdomain feature 
> been introduced?
> 
> Thanks,
> 
> 	Andrés
> 
> 
> Andrés G. Aragoneses wrote:
> > Hey! I upgraded successfully (well, I had to overwrite and 
> write some 
> > script to launch the appropiate version of the 
> nunit-console) and it 
> > seems that the deferred output problem is fixed! So many thanks. I 
> > have also filed a bug against OpenSUSE:
> > https://bugzilla.novell.com/show_bug.cgi?id=410731
> > 
> > However, it seems I'm facing a problem now. I'm getting 
> this exception 
> > when running my tests:
> > 
> > Exception in Gtk# callback delegate
> >   Note: Applications can use 
> GLib.ExceptionManager.UnhandledException 
> > to handle the exception.
> > System.ArgumentException: GCHandle value belongs to a 
> different domain
> >   at System.Runtime.InteropServices.GCHandle.op_Explicit (IntPtr 
> > value) [0x00000]
> > 
> > As you may know, Gtk# cannot work well with AppDomains so I'm 
> > wondering
> > if: is NUnit using more than one appdomain for running the tests?
> > If yes, is there a way to make it work in a one-appdomain 
> mode? And, 
> > do you know if this feature has been introduced in the 2.4 
> series? If 
> > yes, that would explain why I wasn't getting this exception 
> earlier. 
> > If not, maybe there was a bug in earlier versions of NUnit which 
> > prevented from catching this exception, right?
> > 
> > Any insight will be appreciated!
> > 
> > Regards,
> > 
> > 	Andrés
> > 
> > 
> > 
> > Andrés G. Aragoneses wrote:
> >> Wow! I'm surprised that openSUSE11 is shipping so an 
> outdated version 
> >> by default then (you can see this is true here [1], if you 
> look for "nunit"
> >> you'll find mono-nunit-1.9 in the standard repositories).
> >>
> >> Luckily, it seems I can install a newer version from 
> another repository. 
> >> I will try that an report back here. But we should do 
> something about 
> >> that old version shipping (I'll file a bug in bugzilla 
> about it...).
> >>
> >> Thanks!
> >>
> >> 	Andrés
> >>
> >>
> >> [1] http://software.opensuse.org/search
> >>
> >> Charlie Poole wrote:
> >>> Glad to hear it. :-)
> >>>
> >>> That release is almost four years old. I know that issues 
> of delayed 
> >>> printing were dealt with several times by bugs submitted 
> during that 
> >>> period. In fact, NUnit's internal handling of text has been 
> >>> re-designed since then.
> >>>
> >>> Are you in a position to upgrade the version of NUnit you 
> are using? 
> >>> The last release in the 2.2 series was 2.2.10, which shipped in 
> >>> March 2007. The current release is 2.4.7, with a 2.4.8 bug fix 
> >>> release about to come out.
> >>> The 2.5 release is in alpha.
> >>>
> >>> If you upgrade, I suggest doing a side by side install first. And 
> >>> when you finally remove 2.2, save a copy of its 
> nunit.framework.dll 
> >>> for use by your old tests unless you plan to recompile them.
> >>>
> >>> NUnit always does fixes in a new release. So, if some 
> local policy 
> >>> keeps you from upgrading, you're pretty much stuck with the bugs. 
> >>> :-(
> >>>
> >>> Charlie
> >>>
> >>>> -----Original Message-----
> >>>> From: [email protected]
> >>>> [mailto:[email protected]] On Behalf Of 
> >>>> "Andrés G. Aragoneses"
> >>>> Sent: Sunday, July 20, 2008 9:34 AM
> >>>> To: Charlie Poole
> >>>> Cc: [email protected]
> >>>> Subject: Re: [Nunit-users] Output from Console.WriteLine 
> methods is 
> >>>> deferred
> >>>>
> >>>>
> >>>> I'm using NUnit version 2.2.0 and I notice the deferred printing 
> >>>> behaviour even when my unit tests behave normally 
> (without infinite 
> >>>> loops).
> >>>>
> >>>> Regards,
> >>>>
> >>>> 	Andrés
> >>>>
> >>>> Charlie Poole wrote:
> >>>>> That may work, but I'm guessing not. It sounds as if your
> >>>> program may
> >>>>> just be taking up all the cpu cycles.
> >>>>>
> >>>>> This could also be a bug - in which case I hope he's 
> using an old 
> >>>>> version of NUnit. :-)
> >>>>>
> >>>>> Charlie
> >>>>>
> >>>>>> -----Original Message-----
> >>>>>> From: [email protected]
> >>>>>> [mailto:[email protected]] On
> >>>> Behalf Of Eric
> >>>>>> Teutsch
> >>>>>> Sent: Saturday, July 19, 2008 7:39 AM
> >>>>>> To: '"Andrés G. Aragoneses"'; [email protected]
> >>>>>> Subject: Re: [Nunit-users] Output from Console.WriteLine
> >>>> methods is
> >>>>>> deferred
> >>>>>>
> >>>>>> Try to put this after the Console.WriteLine:
> >>>>>> Console.Out.Flush();
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>> -----Original Message-----
> >>>>>> From: [email protected]
> >>>>>> [mailto:[email protected]] On 
> Behalf Of 
> >>>>>> "Andrés G.
> >>>>>> Aragoneses"
> >>>>>> Sent: July 19, 2008 09:23
> >>>>>> To: [email protected]
> >>>>>> Subject: [Nunit-users] Output from Console.WriteLine 
> methods is 
> >>>>>> deferred
> >>>>>>
> >>>>>> Hello. I've been using NUnit for a long time and I 
> think it rocks! 
> >>>>>> Many thanks to all the devs.
> >>>>>>
> >>>>>> And now I would like to ask a question: I've been noticing
> >>>> that, if
> >>>>>> my unit tests write some text to the output
> >>>> (Console.WriteLine), it
> >>>>>> only gets shown when nunit-console finishes all the tests. 
> >>>> This may
> >>>>>> be a feature and not a bug, but there's a problem with this
> >>>>>> behaviour: it prevents easy debugging for when the unit
> >>>> tests enter
> >>>>>> in an infinite loop, because you cannot see what's happenning.
> >>>>>>
> >>>>>> Is there any command line to get direct output from the unit 
> >>>>>> tests without being deferred?
> >>>>>>
> >>>>>> Thanks!
> >>>>>> 		Andrés
> >>>>>>
> >>>>>> --
> >>>>>>
> >>>>>>
> >>>>>> --------------------------------------------------------------
> >>>>>> -----------
> >>>>>> This SF.Net email is sponsored by the Moblin Your Move 
> >>>>>> Developer's challenge Build the coolest Linux based 
> applications 
> >>>>>> with
> >>>> Moblin SDK
> >>>>>> & win great prizes Grand prize is a trip for two to an Open 
> >>>>>> Source event anywhere in the world 
> >>>>>> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> >>>>>> _______________________________________________
> >>>>>> Nunit-users mailing list
> >>>>>> [email protected] 
> >>>>>> https://lists.sourceforge.net/lists/listinfo/nunit-users
> >>>>>>
> >>>>>>
> >>>>>> --------------------------------------------------------------
> >>>>>> -----------
> >>>>>> This SF.Net email is sponsored by the Moblin Your Move 
> >>>>>> Developer's challenge Build the coolest Linux based 
> applications 
> >>>>>> with
> >>>> Moblin SDK
> >>>>>> & win great prizes Grand prize is a trip for two to an Open 
> >>>>>> Source event anywhere in the world 
> >>>>>> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> >>>>>> _______________________________________________
> >>>>>> Nunit-users mailing list
> >>>>>> [email protected] 
> >>>>>> https://lists.sourceforge.net/lists/listinfo/nunit-users
> >>>>>>
> >>>>>
> >>>> 
> -------------------------------------------------------------------
> >>>> ---
> >>>>> --- This SF.Net email is sponsored by the Moblin Your Move
> >>>> Developer's
> >>>>> challenge Build the coolest Linux based applications with
> >>>> Moblin SDK &
> >>>>> win great prizes Grand prize is a trip for two to an Open
> >>>> Source event
> >>>>> anywhere in the world
> >>>>> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> >>>> --------------------------------------------------------------
> >>>> -----------
> >>>> This SF.Net email is sponsored by the Moblin Your Move 
> Developer's 
> >>>> challenge Build the coolest Linux based applications with Moblin 
> >>>> SDK & win great prizes Grand prize is a trip for two to an Open 
> >>>> Source event anywhere in the world 
> >>>> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> >>>> _______________________________________________
> >>>> Nunit-users mailing list
> >>>> [email protected]
> >>>> https://lists.sourceforge.net/lists/listinfo/nunit-users
> >>>>
> >>>
> >>> 
> --------------------------------------------------------------------
> >>> ----- This SF.Net email is sponsored by the Moblin Your Move 
> >>> Developer's challenge Build the coolest Linux based applications 
> >>> with Moblin SDK & win great prizes Grand prize is a trip 
> for two to 
> >>> an Open Source event anywhere in the world 
> >>> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> >>
> >> 
> ---------------------------------------------------------------------
> >> ---- This SF.Net email is sponsored by the Moblin Your Move 
> >> Developer's challenge Build the coolest Linux based 
> applications with 
> >> Moblin SDK & win great prizes Grand prize is a trip for two to an 
> >> Open Source event anywhere in the world 
> >> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> > 
> > 
> > 
> ----------------------------------------------------------------------
> > --- This SF.Net email is sponsored by the Moblin Your Move 
> Developer's 
> > challenge Build the coolest Linux based applications with 
> Moblin SDK & 
> > win great prizes Grand prize is a trip for two to an Open 
> Source event 
> > anywhere in the world 
> > http://moblin-contest.org/redirect.php?banner_id=100&url=/
> 
> 
> --------------------------------------------------------------
> -----------
> This SF.Net email is sponsored by the Moblin Your Move 
> Developer's challenge Build the coolest Linux based 
> applications with Moblin SDK & win great prizes Grand prize 
> is a trip for two to an Open Source event anywhere in the 
> world http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Nunit-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/nunit-users
> 



-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/