.NET Forum / .NET Framework / Component Services / September 2005
Returning Errors in COM+ using Autocomplete
|
|
Thread rating:  |
Alfredo - 07 Aug 2005 17:18 GMT Hi,
I have a question. In my COM+ methods and functions i use Autocomplete instead of SetComplete and SetAbort, but i dont know what do i have to return in each function, because i have to propagate the error in my COM+ classes, in order to function Autocomplete attribute.
What do you recommend? I think it is better do try catch and throw ex? obviously logging the exception. This is the rigth use?
Thanks,
Alfredo Barrientos
Tomas Restrepo (MVP) - 07 Aug 2005 19:43 GMT Alfredo,
> I have a question. In my COM+ methods and functions i use Autocomplete > instead of SetComplete and SetAbort, but i dont know what do i have to [quoted text clipped - 3 lines] > What do you recommend? I think it is better do try catch and throw ex? > obviously logging the exception. This is the rigth use? With AutoComplete, you need to use exceptions. The COM+/EnterpriseServices interceptors will catch the exception and automatically vote to abort the transaction for you. If your component needs to log the exception, just use a try/catch block, log the exception and immediately rethrow it by using an empty "throw;" statement in the catch block.
Alfredo - 07 Aug 2005 22:29 GMT Thanks Tomas,
I dont understand the last sentecen, How can i rethrow and throw a new exception, could you show me some code?
Thanks,
Alfredo Barrientos
Tomas Restrepo (MVP) - 08 Aug 2005 02:28 GMT Alfredo,
> I dont understand the last sentecen, How can i rethrow and throw a new > exception, could you show me some code? [AutoComplete] public void DoSomething() { try { // do your main logic } catch ( Exception ex ) { // log ex into whetever throw; } }
 Signature Tomas Restrepo tomasr@mvps.org http://www.winterdom.com/
Alfredo - 08 Aug 2005 16:11 GMT Thank you very much Tomas. Just one little question, "Throw" is equal to "Throw ex"?
Thanks
Alfredo Barrientos
Tomas Restrepo (MVP) - 09 Aug 2005 00:58 GMT Alfredo,
> Thank you very much Tomas. Just one little question, "Throw" is equal > to "Throw ex"? Not at all! "throw;" just lets the current exception go on, as if it hadn't been handled. "Throw ex;", on the other hand, throws the same exception object as if it was a new exception altogether, and thus overwrites important information such as the original stack trace.
 Signature Tomas Restrepo tomasr@mvps.org http://www.winterdom.com/
Alfredo - 11 Aug 2005 17:56 GMT Hi Tomas, thanks for answering.
I have other question, in all examples i have never seen the use of finally in try catch instruction using autocomplete attribute in COM+ application?
Is there any trouble if i use try catch and finally with autocomplete attribute?
Thanks,
Alfredo Barrientos
Tomas Restrepo (MVP) - 12 Aug 2005 01:00 GMT Alfredo,
> Hi Tomas, thanks for answering. > > I have other question, in all examples i have never seen the use of > finally in try catch instruction using autocomplete attribute in COM+ > application? The one I posted does.
> Is there any trouble if i use try catch and finally with autocomplete > attribute? Not as long as you still let a transaction flow out of the method on an error (either the original one or a new exception), to ensure the transaction gets marked for abortion. Otherwise, you'll soon meet a wonderful set of errors with messages like "Transaction wanted to commit but transaction aborted" and such....
 Signature Tomas Restrepo tomasr@mvps.org http://www.winterdom.com/
Alfredo - 16 Aug 2005 17:33 GMT Hi Tomas,
Thanks for everything! I have additional question, have you worked with COM+ in Windows 2003 with no ApplicationAccessControl(True), and calling it from ASP.Net Page? i am getting an error "Access Denied". My ASP.Net is running in an application with anonymous access.
Thanks,
Alfredo Barrientos
Tomas Restrepo (MVP) - 17 Aug 2005 00:42 GMT Alfredo,
> Thanks for everything! I have additional question, have you worked with > COM+ in Windows 2003 with no ApplicationAccessControl(True), and > calling it from ASP.Net Page? i am getting an error "Access Denied". My > ASP.Net is running in an application with anonymous access. On .NET 1.1, if you don't use the security attributes at the assembly level to disable security, it will be by default enabled when you register the assembly using regsvcs.exe. If you leave it like that, you'll have to manually go in later to the MMC console and either disable it again or configure the necessary roles and permissions to enable access (for *any* user or application... ASP.NET is not special in that regard).
 Signature Tomas Restrepo tomasr@mvps.org http://www.winterdom.com/
Alfredo - 21 Aug 2005 19:06 GMT Hi Tomas, Thanks you very much.
Do you know some guide or how to in microsoft.com which explains this behavior?
Thanks,
Alfredo Barrientos
Alfredo - 23 Aug 2005 19:36 GMT Hi Thomas,
Is there any sample site like Petshop, Duwamish, Fitch & Mather, but using COM+ Security Attributes?
Thanks,
Alfredo Barrientos
Todd - 22 Sep 2005 20:41 GMT Hi Tomas,
I have an additional question on this - if in your example "log ex into whatever" means writing to a database wouldn't the fact that an exception is being thrown cause the logged error to be rolled back as well? How can I get that level of control over transactions? For example
<Transaction Root Here> Public Sub DoSomething() CreateRecordA() try CreateMoreRecords() catch CreateExceptionRecord() UpdateRecordA_wError() end try End Sub
If CreateMoreRecords() fails I want to roll back any of it's updates but let RecordA commit and also flag it as error with the Exception record logged.
Thanks Todd Langdon
> Alfredo, > [quoted text clipped - 11 lines] > } > } Tomas Restrepo (MVP) - 23 Sep 2005 00:56 GMT Todd,
> I have an additional question on this - if in your example "log ex into > whatever" means writing to a database wouldn't the fact that an exception > is > being thrown cause the logged error to be rolled back as well? Actually, we are not logging to the database there, for that very reason :) Actually, in our case we log the error to a flat file, or the machine's event log, for example.
> How can I get > that level of control over transactions? For example [quoted text clipped - 13 lines] > let > RecordA commit and also flag it as error with the Exception record logged. In that case you got to call a second ServicedComponent that spawns a new transaction (TransactionOption.RequiresNew) or gets the component out of the existing transaction and leaves it without one (TransactionOption.NotSupported). If you're using Windows Server 2003, you can also accomplish this using ServiceConfig and ServiceDomain.Enter(), as well.
 Signature Tomas Restrepo tomasr@mvps.org http://www.winterdom.com/
Free MagazinesGet 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 ...
|
|
|