Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Component Services / December 2003

Tip: Looking for answers? Try searching our database.

Strange behavior with Custom Exception and ServicedComponent

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John Leyva - 24 Oct 2003 23:16 GMT
This is the enviroment

A WinForm application call a ServicedComponent, it is activated in Server Mode.
This ServicedComponent, throw a CustomException that is catched by de WinForm Application.

When the ServicedCompoent does not implement another Interface, the exception catched by
the application is CustomException, like I expected.
However when the ServicedCompoent does implement another Interfacem the exception catched by
the application is ApplicationException.

thanks for any help.

CODE

-- Custom Exception, Defined in another class library, ----

[Serializable]
public class CustomException : ApplicationException
{

 protected CustomException(SerializationInfo info,
StreamingContext context) : base(info, context) {}

 public CustomException() : base() {}

 public CustomException(string message) : base(message) {}

 public CustomException(string message,Exception inner) :
base(message, inner) {}
}


-- Class Library with ServicedComponent, Activation Mode :
Server---------------------------------

public interface IThrowExcepcion: IDisposable
{
 void ThrowCustomException(string Mensaje);
}

// In this way, works. But, if i implement
IThrowExcepcion, it does not work
public class ThrowExcepcion:
ServicedComponent //,IThrowExcepcion

{
 public ThrowExcepcion()  {}

 public void ThrowCustomException(string Mensaje)
 {
   throw new ION.Servicios.Excepciones.CustomExcepcion
(Mensaje);
 }
}


--- To show the case i useo the next code  

try
{
 using (Test.ThrowExcepcion Tester = new
(Test.ThrowExcepcion())
 {
   Tester.ThrowCustomException ("Prueba1");
 }
}
catch (CustomExcepcion E)
{
 // if i do not implement IThrowExcepcion, it execute
this code
 MessageBox.Show ("with IThrowExcepcion");
}
catch (ApplicationException E)
{
 // if i implement IThrowExcepcion, it execute this code
Alexey Kuchmenko - 18 Dec 2003 12:56 GMT
The possible solution is to inclide in nterface method an [out] parameter of
custom type. This type should be serializabe, of course.
Im also get this problem now. I have an application, logic is implmented as
regular assembly, but now it must be placed into COM+. So, now I have to add
the parameter to all the methods and then rewrite ALL the client code! But I
don't want this silly work! Does anyone know some other solution?!

> This is the enviroment
>
[quoted text clipped - 71 lines]
>   MessageBox.Show ("without IThrowExcepcion");
> }

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.