473,387 Members | 1,528 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

I don't know how to handle this

I created a COM+ component and I need to pass an event to the client app.
Here is my scenario.

I have this component that checks if a product number is valid

.....................

Public Class ProductChecker

Protected WithEvents myOtherCompoent As new OtherComponent

...............

Public Function IsProductValid(sProdID as string) As Boolean Implements
IProdChecker.IsProductValid

Try

With myOtherCompoent

..ProdID = sProdID
..ValidateProduct

End With

Return True
Catch ex As OtherComponent.Exception

End Try

End Function

End Class
When a client calls this component it returns true if product is valid. This
component basically calls the .ValidateProduct from another .dll
(OtherComponent.dll) but this is the problem. The other .dll
(OtherComponent.dll) raises an exception if the product is invalid and I need
to also pass that exception message back to the client. At the moment I can
catch the exception in Catch ex As OtherComponent.Exception but how do I pass
it to the client. I tried

Catch ex As OtherComponent.Exception

Return ex.message

but I got an error because the function that initiates the error (Public
Function IsProductValid) returns type Boolean. Any ideas?

Basically the component should return True if product is valid of false if
invalid alsong with reason (exceptions returned buy other dll) as well.

Thanks

Sep 28 '05 #1
3 1493
Chris wrote:
it to the client. I tried

Catch ex As OtherComponent.Exception

Return ex.message


If you're able to catch the exception from the other .dll, then just
re-throw it or throw a new exception and set its InnerException
property to the exception you originally caught:

Try
'blah
Catch ex As OtherComponent.Exception
Throw 'Throw by itself, just re-throws the same
exception
End Try

OR

Try
'Blah
Catch ex As OtherComponent.Exception
Throw New MyCustomException(ex) 'throw a different exception and
pass ex
End Try

Just a thought

Sep 28 '05 #2
Hi,
Thanks for the info. How do I catch this in the com+ client? Do you know
where I can find additional info.

Thanks

"Chris Dunaway" wrote:
Chris wrote:
it to the client. I tried

Catch ex As OtherComponent.Exception

Return ex.message


If you're able to catch the exception from the other .dll, then just
re-throw it or throw a new exception and set its InnerException
property to the exception you originally caught:

Try
'blah
Catch ex As OtherComponent.Exception
Throw 'Throw by itself, just re-throws the same
exception
End Try

OR

Try
'Blah
Catch ex As OtherComponent.Exception
Throw New MyCustomException(ex) 'throw a different exception and
pass ex
End Try

Just a thought

Sep 28 '05 #3
Thanks. It worked!

"Chris Dunaway" wrote:
Chris wrote:
it to the client. I tried

Catch ex As OtherComponent.Exception

Return ex.message


If you're able to catch the exception from the other .dll, then just
re-throw it or throw a new exception and set its InnerException
property to the exception you originally caught:

Try
'blah
Catch ex As OtherComponent.Exception
Throw 'Throw by itself, just re-throws the same
exception
End Try

OR

Try
'Blah
Catch ex As OtherComponent.Exception
Throw New MyCustomException(ex) 'throw a different exception and
pass ex
End Try

Just a thought

Sep 28 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

303
by: mike420 | last post by:
In the context of LATEX, some Pythonista asked what the big successes of Lisp were. I think there were at least three *big* successes. a. orbitz.com web site uses Lisp for algorithms, etc. b....
28
by: Xiaotian Sun | last post by:
I added the following line to the header of my html file <meta http-equiv="content-type" content="text/html; charset=utf-8"> hoping browsers will use UTF-8 encoding. But all browsers I tried...
16
by: G Patel | last post by:
Hi, If I want to call functions that don't return int without declaring them, will there be any harm? I only want to assign the function(return value) to the type that it returns, so I don't...
7
by: Kevin Frey | last post by:
Using .NET 1.1. We have a mixed-mode assembly written in Managed C++ that we are using from an ASP.NET application that has been coded using C#. The mixed-mode assembly has its own...
3
by: smorrey | last post by:
Howdy folks, I recently purchased a book on C++ MUD creation and it features alot of nifty tidbits. The book is MUD GAME PROGRAMMING by Ron Penton Publisher: Premier Press Anyways of...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.