So, I haven't actually looked at the code since I left a week and a half
ago, but I think I know what's going on.

It seems to me like there's a flaw in the way exceptions are handled.  (In
all honesty, it seems like exception handling through the entire system
needs some work.)

The following is my guess, and not necessarily accurate:
Basically, the Executor has its AppDomain (implicitly) and it runs the
GThread in a different AppDomain, which it "manages".  In order to get any
messages from the GThread back to the originating GApp, the Executor needs
to recognize them and pass them through.  Because of the manifest
declaration, you've got the DLL and thus the classes you need on the
executing machine, as well as your custom exception.  So, in the GThread,
when it throws the exception, it throws the CustomException, which it finds
and it understands and there's no problem.

Since that needs to get back to the original GApp, the Executor captures
that exception, and tries to pass it through.  BUT, while the GThread knows
what CustomException is, the Executor doesn't.  So, the Executor throws its
SerializationException telling you that it doesn't know what the custom
exception is, which is exactly what's happening.

However, when you copy the DLL to the machine with the Executor, it _is_
able to find the CustomException, and that's why it works in that case.
(FYI, I was not actually able to reproduce that "working" state you
described).

So it seems like somehow, at least in the case of exceptions, that the
Executor should load any custom exceptions required by GThreads into its own
AppDomain.

Again, not going to guarantee that's actually what's happening, but I think
that's what it is.

Jonathan

On 11/10/06, Matt Valerio < [EMAIL PROTECTED]> wrote:
> > > > >
> > > > > Hey everyone,
> > > > >
> > > > > I just wrote a sample test application that duplicates my
> > > > > problem.  It is a quick-n-dirty windows form app that starts up 10
> > > > > RemoteThread GThreads and adds them to the GApplication, and starts 
> > > > > it.
> > > > >
> > > > > The RemoteThread thread throws a CustomException only if its
> > > > > tracking number is 5.  So ony 1 in 10 of the threads throws the 
> > > > > exception.
> > > > > Both RemoteThread and CustomException are in their own DLL,
> > > > > RemoteThreadLib.dll that is separate from the main windows forms
> > > > > app.
> > > > >
> > > > > Here's the code I'm using to create and start the GApplication:
> > > > >
> > > > > GConnection conn = new GConnection(
> > > > >     txtHost.Text,
> > > > >     Int32.Parse(txtPort.Text),
> > > > >     txtUsername.Text,
> > > > >     txtPassword.Text);
> > > > > GApplication app = new GApplication(conn);
> > > > >
> > > > > app.Manifest.Add(new
> > > > > ModuleDependency(typeof(RemoteThread).Module));
> > > > >
> > > > > for (int i = 1; i < 10; i++)
> > > > > {
> > > > >     app.Threads.Add(new RemoteThread(i));
> > > > > }
> > > > >
> > > > > app.ThreadFinish += new GThreadFinish(OnThreadFinish);
> > > > > app.ThreadFailed += new GThreadFailed(OnThreadFailed);
> > > > > app.ApplicationFinish += new
> > > > > GApplicationFinish(OnApplicationFinish);
> > > > >
> > > > > app.Start();
> > > > >
> > > > > When I run this, I get a SerializationException, like what i was
> > > > > describing before.
> > > > > The thread (TrckingNumber = 5) failed with exception message:
> > > > > System.Runtime.Serialization.SerializationException : Type is not
> > > > > resolved for member 'RemoteThreadLib.CustomException,RemoteThreadLib,
> > > > > Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
> > > > >    at Alchemi.Executor.AppDomainExecutor.ExecuteThread (Byte[]
> > > > > thread)
> > > > >    at Alchemi.Executor.GExecutor.ExecuteThreadInAppDomain()
> > > > >
> > > > > So it sounds like there is a problem discovering where the
> > > > > CustomException type is defined (in what DLL).  So I copied the
> > > > > RemoteThreadLib.dll onto the manager (C:\Program
> > > > > Files\Alchemi\Manager\) and ran it again.  No change, so the problem 
> > > > > is not
> > > > > with the manager.
> > > > >
> > > > > Then I copied RemoteThreadLib.dll onto each Executor (yeah it was
> > > > > a pain) into C:\Program Files\Alchemi\Executor\ and ran it again.  
> > > > > This time
> > > > > it worked!  The exception instead says:
> > > > >
> > > > > The thread (TrackingNumber = 5) failed with exception message:
> > > > > RemoteThreadLib.CustomException: The TrackingNumber is 5!
> > > > >    at RemoteThreadLib.RemoteThread.Start()
> > > > >    at Alchemi.Executor.AppDomainExecutor.ExecuteThread (Byte[]
> > > > > thread)
> > > > >    at Alchemi.Executor.AppDomainExecutor.ExecuteThread(Byte[]
> > > > > thread)
> > > > >    at Alchemi.Executor.GExecutor.ExecuteThreadInAppDomain()
> > > > >
> > > > > This is what I wanted to happen.
> > > > >
> > > > > So, it appears that when Alchemi throws exceptions, it does not
> > > > > look at the modules that are loaded into memory (serialized over from 
> > > > > the
> > > > > manager) as part of the GApplication's manifest.  It only looks on 
> > > > > disk to
> > > > > resolve the type.
> > > > >
> > > > > Is this a bug?  Or am I doing something wrong here.
> > > > >
> > > > > I can zip up my sample project if anyone wants to try it out and
> > > > > see what I'm talking about.  Email me if you want it.
> > > > >
> > > > > Any help would be greatly appreciated.  I've been beating my head
> > > > > against a wall with this because my engineering simulations will run 
> > > > > for
> > > > > about 3 hours and then crash because of this -- it's pretty hard to 
> > > > > debug
> > > > > something that only happens every 3-4 hours!
> > > > >
> > > > > Anyway, thanks again, hope that some good can come of this.
> > > > >
> > > > > -Matt
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > On 11/7/06, Jonathan Mitchem < [EMAIL PROTECTED]> wrote:
> > > > > >
> > > > > > I'll take a look at this tonight and get back to you.
> > > > > >
> > > > > > Jonathan
> > > > > >
> > > > > > On 11/7/06, Matt Valerio < [EMAIL PROTECTED] > wrote:
> > > > > > >
> > > > > > > Hmm.  I think so?  I don't explicitly say that my exception
> > > > > > > implements ISerializable, but it derives from Exception which 
> > > > > > > does.  I do
> > > > > > > override GetObjectData.
> > > > > > >
> > > > > > > Here's the code for my TaskNotCompletedException class:
> > > > > > >
> > > > > > >
> > > > > > >     [Serializable]
> > > > > > >     public class TaskNotCompletedException : Exception
> > > > > > >     {
> > > > > > >         #region Constructors
> > > > > > >         public TaskNotCompletedException()
> > > > > > >             : base()
> > > > > > >         {
> > > > > > >         }
> > > > > > >
> > > > > > >         public TaskNotCompletedException(string taskName)
> > > > > > >             : base()
> > > > > > >         {
> > > > > > >             this.TaskName = taskName;
> > > > > > >         }
> > > > > > >
> > > > > > >         public TaskNotCompletedException(string taskName,
> > > > > > > string message)
> > > > > > >             : base(message)
> > > > > > >         {
> > > > > > >             this.TaskName = taskName;
> > > > > > >         }
> > > > > > >
> > > > > > >         public TaskNotCompletedException(string taskName,
> > > > > > > string message, Exception innerException)
> > > > > > >             : base(message, innerException)
> > > > > > >         {
> > > > > > >             this.TaskName = taskName;
> > > > > > >         }
> > > > > > >
> > > > > > >         public TaskNotCompletedException(SerializationInfo
> > > > > > > info, StreamingContext context)
> > > > > > >             : base(info, context)
> > > > > > >         {
> > > > > > >             this.TaskName = info.GetString("TaskName");
> > > > > > >         }
> > > > > > >         #endregion
> > > > > > >
> > > > > > >
> > > > > > >         #region Property - TaskName
> > > > > > >         private string m_TaskName = "";
> > > > > > >         public string TaskName
> > > > > > >         {
> > > > > > >             get
> > > > > > >             {
> > > > > > >                 return this.m_TaskName;
> > > > > > >             }
> > > > > > >             set
> > > > > > >             {
> > > > > > >                 this.m_TaskName = value;
> > > > > > >             }
> > > > > > >         }
> > > > > > >         #endregion
> > > > > > >
> > > > > > >
> > > > > > >         public override void GetObjectData(SerializationInfo
> > > > > > > info, StreamingContext context)
> > > > > > >         {
> > > > > > >             base.GetObjectData(info, context);
> > > > > > >             info.AddValue("TaskName", this.TaskName);
> > > > > > >         }
> > > > > > >
> > > > > > >
> > > > > > >         public override string Message
> > > > > > >         {
> > > > > > >             get
> > > > > > >             {
> > > > > > >                 String s = base.Message;
> > > > > > >                 s += Environment.NewLine;
> > > > > > >                 s += "TaskName: " + this.TaskName;
> > > > > > >                 return s;
> > > > > > >             }
> > > > > > >         }
> > > > > > >
> > > > > > >     }
> > > > > > >
> > > > > > > Am I still doing something wrong?
> > > > > > >
> > > > > > > Thanks for your help,
> > > > > > > -Matt
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > On 11/7/06, Jonathan Mitchem <[EMAIL PROTECTED]> wrote:
> > > > > > > >
> > > > > > > > From what it looks like to me, the exception is being thrown
> > > > > > > > in the Executor whenever the thread is Start()ed.
> > > > > > > >
> > > > > > > > You didn't mention it, but do you implement ISerializable?
> > > > > > > >
> > > > > > > >
> > > > > > > > Jonathan
> > > > > > > >
> > > > > > > >  On 11/4/06, Matt Valerio <[EMAIL PROTECTED]> wrote:
> > > > > > > >
> > > > > > > > > Has anyone else run into a problem like this?
> > > > > > > > >
> > > > > > > > > System.Runtime.Serialization.SerializationException: Type
> > > > > > > > > is not resolved for member '
> > > > > > > > > Fsda.Tasks.TaskNotCompletedException,FSDA_Driver, Version=
> > > > > > > > > 0.3.0.1, Culture=neutral, PublicKeyToken=null'.
> > > > > > > > >     at Alchemi.Executor.AppDomainExecutor.ExecuteThread(Byte[]
> > > > > > > > > thread)
> > > > > > > > >    at Alchemi.Executor.GExecutor.ExecuteThreadInAppDomain()
> > > > > > > > >
> > > > > > > > > Apparently there is an exception
> > > > > > > > > (TaskNotCompletedException, a custom exception that I wrote) 
> > > > > > > > > that gets
> > > > > > > > > thrown from within my (class inherited from) GThread.
> > > > > > > > >
> > > > > > > > > My TaskNotCompletedException is written correctly( I
> > > > > > > > > think), because it:
> > > > > > > > > 1) inherits from Exception
> > > > > > > > > 2) is marked as [Serializable]
> > > > > > > > > 3) provides all the same constructors as Exception,
> > > > > > > > > including the one with SerializationContext and 
> > > > > > > > > SerializationInfo parameters
> > > > > > > > > 4) overrides GetObjectData
> > > > > > > > >
> > > > > > > > > Did I miss something?
> > > > > > > > >
> > > > > > > > > How can you find out on which computer the exception is
> > > > > > > > > being thrown (executor, manager, or client)?
> > > > > > > > >
> > > > > > > > > Or is this SerializationException being thrown for another
> > > > > > > > > reason....
> > > > > > > > >
> > > > > > > > > Any help would be greatly appreciated.
> > > > > > > > >
> > > > > > > > > Thanks,
> > > > > > > > > -Matt
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > -------------------------------------------------------------------------
> > > > > > > > > Using Tomcat but need to do more? Need to support web
> > > > > > > > > services, security?
> > > > > > > > > Get stuff done quickly with pre-integrated technology to
> > > > > > > > > make your job easier
> > > > > > > > > Download IBM WebSphere Application Server v.1.0.1 based on
> > > > > > > > > Apache Geronimo
> > > > > > > > >
> > > > > > > > > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> > > > > > > > >
> > > > > > > > > _______________________________________________
> > > > > > > > > alchemi-users mailing list
> > > > > > > > > [email protected]
> > > > > > > > > https://lists.sourceforge.net/lists/listinfo/alchemi-users
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> > >
> >
>
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Alchemi-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/alchemi-developers

Reply via email to