473,396 Members | 2,011 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,396 software developers and data experts.

throwing exceptions from COM+

guy
When trying to throw a custom exception from a COM+ component to a client
using an interface as suggested by microsoft i am getting an "Object
reference not set to an instance of an object."
However when executing the code outside of COM+ the application behaves
correctly.

Public Interface IExceptionGenerator
Sub GenerateException(ByVal Ex As Exception, ByVal SourceAssembly As
String, _
ByVal SourceModule As String, ByVal
SourceProcedure As String)
End Interface

<ClassInterface(ClassInterfaceType.AutoDual), _
Transaction(TransactionOption.Supported), _
Serializable()> _
Public Class ExceptionGenerator
Inherits ServicedComponent
Implements IExceptionGenerator

Public Sub New()
MyBase.new()
End Sub

Public Sub GenerateException(ByVal Ex As System.Exception, ByVal
SourceAssembly As String, ByVal SourceModule As String, ByVal SourceProcedure
As String) Implements IExceptionGenerator.GenerateException

Dim CustEx As New CustomException(Ex, SourceAssembly, SourceModule,
SourceProcedure)
Throw (CustEx)

End Sub
End Class

Oct 17 '05 #1
2 1121
this article might help:

http://msdn.microsoft.com/msdnmag/is...M/default.aspx

HTH

Ollie Riches
"guy" <gu*@discussions.microsoft.com> wrote in message
news:E7**********************************@microsof t.com...
When trying to throw a custom exception from a COM+ component to a client
using an interface as suggested by microsoft i am getting an "Object
reference not set to an instance of an object."
However when executing the code outside of COM+ the application behaves
correctly.

Public Interface IExceptionGenerator
Sub GenerateException(ByVal Ex As Exception, ByVal SourceAssembly As
String, _
ByVal SourceModule As String, ByVal
SourceProcedure As String)
End Interface

<ClassInterface(ClassInterfaceType.AutoDual), _
Transaction(TransactionOption.Supported), _
Serializable()> _
Public Class ExceptionGenerator
Inherits ServicedComponent
Implements IExceptionGenerator

Public Sub New()
MyBase.new()
End Sub

Public Sub GenerateException(ByVal Ex As System.Exception, ByVal
SourceAssembly As String, ByVal SourceModule As String, ByVal
SourceProcedure
As String) Implements IExceptionGenerator.GenerateException

Dim CustEx As New CustomException(Ex, SourceAssembly, SourceModule,
SourceProcedure)
Throw (CustEx)

End Sub
End Class

Oct 17 '05 #2
guy
thanks Ollie, unfortunately thats the article we started from!

cheers

guy

"Ollie Riches" wrote:
this article might help:

http://msdn.microsoft.com/msdnmag/is...M/default.aspx

HTH

Ollie Riches
"guy" <gu*@discussions.microsoft.com> wrote in message
news:E7**********************************@microsof t.com...
When trying to throw a custom exception from a COM+ component to a client
using an interface as suggested by microsoft i am getting an "Object
reference not set to an instance of an object."
However when executing the code outside of COM+ the application behaves
correctly.

Public Interface IExceptionGenerator
Sub GenerateException(ByVal Ex As Exception, ByVal SourceAssembly As
String, _
ByVal SourceModule As String, ByVal
SourceProcedure As String)
End Interface

<ClassInterface(ClassInterfaceType.AutoDual), _
Transaction(TransactionOption.Supported), _
Serializable()> _
Public Class ExceptionGenerator
Inherits ServicedComponent
Implements IExceptionGenerator

Public Sub New()
MyBase.new()
End Sub

Public Sub GenerateException(ByVal Ex As System.Exception, ByVal
SourceAssembly As String, ByVal SourceModule As String, ByVal
SourceProcedure
As String) Implements IExceptionGenerator.GenerateException

Dim CustEx As New CustomException(Ex, SourceAssembly, SourceModule,
SourceProcedure)
Throw (CustEx)

End Sub
End Class


Oct 18 '05 #3

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

Similar topics

5
by: Mark Oueis | last post by:
I've been struggling with this question for a while. What is better design? To design functions to return error codes when an error occures, or to have them throw exceptions. If you chose the...
21
by: mihai | last post by:
People say that is a bad technique to throw exception from constructors; and that the solution would be to create a function _create_ to initialize an object. What about copy constructors? How...
1
by: Farooq Khan | last post by:
i'm writing a class library having following code snippet. i want this class to report an error (by throwing an Exception) to the application using this class library. the problem is that within...
40
by: Kevin Yu | last post by:
is it a bad programming design to throw exception in the try block then catch it??
15
by: Sek | last post by:
Gurus, I am wondering whether it is right to throw an exception from a Property of an object. To get into it further, is it okay to throw exception during 'get' operation? I was searching...
4
by: Sridhar | last post by:
Hi, I would like to know the general procedure to throw exceptions. Lets say I have a datagrid in my webpage and I am pulling the data for my webpage using a function. The function accepts...
40
by: Sek | last post by:
Is it appropriate to throw exception from a constructor? Thats the only way i could think of to denote the failure of constructor, wherein i am invoking couple of other classes to initialise the...
1
by: usenet | last post by:
I wrote some sample code (see below) for nested exception throwing i.e. my catch blocks are throwing exceptions of their own (for simplicity I used standard exceptions). I am getting some...
4
by: Jay Dee | last post by:
I have a query about throwing exceptions. To throw an exception I type something like: try { // do somthing } catch (ArgumentOutOfRangeException) {
21
by: Chris M. Thomasson | last post by:
Is it every appropriate to throw in a dtor? I am thinking about a simple example of a wrapper around a POSIX file... ________________________________________________________________________ class...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.