Error in Logging App Block

Topics: Exception Handling Application Block, Logging Application Block
Aug 18, 2009 at 6:22 PM

I'm using Ent Lib. in business layer. I have a Exception policy which logs in to flat text file. when an exception occured in business component, Its logging error successfully but returns an Invoke Exception. This occurs only when I configure business layer in the application Server. But It works fine when I configure both UI and business layer in my local computer.  PLEASE ADVICE...THANKS IN ADVANCE.

Detailed exception -

Catch{
bool rethrow = ExceptionPolicy.HandleException(ex, "Log Only Policy");
}


Server stack trace:
   at System.RuntimeMethodHandle._SerializationInvoke(Object target, SignatureStruct& declaringTypeSig, SerializationInfo info, StreamingContext context)
   at System.RuntimeMethodHandle.SerializationInvoke(Object target, SignatureStruct declaringTypeSig, SerializationInfo info, StreamingContext context)
   at System.Reflection.RuntimeConstructorInfo.SerializationInvoke(Object target, SerializationInfo info, StreamingContext context)
   at System.Runtime.Serialization.ObjectManager.CompleteISerializableObject(Object obj, SerializationInfo info, StreamingContext context)
   at System.Runtime.Serialization.ObjectManager.FixupSpecialObject(ObjectHolder holder)
   at System.Runtime.Serialization.ObjectManager.DoFixups()
   at System.Runtime.Serialization.Formatters.Soap.ObjectReader.Deserialize(HeaderHandler handler, ISerParser serParser)
   at System.Runtime.Serialization.Formatters.Soap.SoapFormatter.Deserialize(Stream serializationStream, HeaderHandler handler)
   at System.Runtime.Remoting.Channels.CoreChannel.DeserializeSoapResponseMessage(Stream inputStream, IMessage requestMsg, Header[] h, Boolean bStrictBinding)
   at System.Runtime.Remoting.Channels.SoapClientFormatterSink.DeserializeMessage(IMethodCallMessage mcm, ITransportHeaders headers, Stream stream)
   at System.Runtime.Remoting.Channels.SoapClientFormatterSink.SyncProcessMessage(IMessage msg)

Exception rethrown at [0]:
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at IBizFramework.IBizFacade.AuthenticateAppUser(String strUserName)
   at SupplierCommunicationPortal.scpLogin.btnLogin_Click(Object sender, EventArgs e) in D:\Applications\Supplier Communication Portal\Source\SupplierCommunicationPortal\SCPWeb\scpLogin.aspx.cs:line 78

 

Aug 19, 2009 at 1:23 AM

Where is the catch statement you posted above? Is it in the business layer?  What is the value of PostHandlingAction of the Log Only Policy?

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Aug 19, 2009 at 12:58 PM

Thanks for looking into this.

Catch statement is in Business layer. postHandlingAction="None". 

Complete Error Message:

{System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidCastException: Specified cast is not valid.

at System.Runtime.Remoting.Messaging.LogicalCallContext..ctor(SerializationInfo info, StreamingContext context)

--- End of inner exception stack trace ---

Server stack trace:

at System.RuntimeMethodHandle._SerializationInvoke(Object target, SignatureStruct& declaringTypeSig, SerializationInfo info, StreamingContext context)

at System.RuntimeMethodHandle.SerializationInvoke(Object target, SignatureStruct declaringTypeSig, SerializationInfo info, StreamingContext context)

at System.Reflection.RuntimeConstructorInfo.SerializationInvoke(Object target, SerializationInfo info, StreamingContext context)

at System.Runtime.Serialization.ObjectManager.CompleteISerializableObject(Object obj, SerializationInfo info, StreamingContext context)

at System.Runtime.Serialization.ObjectManager.FixupSpecialObject(ObjectHolder holder)

at System.Runtime.Serialization.ObjectManager.DoFixups()

at System.Runtime.Serialization.Formatters.Soap.ObjectReader.Deserialize(HeaderHandler handler, ISerParser serParser)

at System.Runtime.Serialization.Formatters.Soap.SoapFormatter.Deserialize(Stream serializationStream, HeaderHandler handler)

at System.Runtime.Remoting.Channels.CoreChannel.DeserializeSoapResponseMessage(Stream inputStream, IMessage requestMsg, Header[] h, Boolean bStrictBinding)

at System.Runtime.Remoting.Channels.SoapClientFormatterSink.DeserializeMessage(IMethodCallMessage mcm, ITransportHeaders headers, Stream stream)

at System.Runtime.Remoting.Channels.SoapClientFormatterSink.SyncProcessMessage(IMessage msg)

Exception rethrown at [0]:

at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)

at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)

at IBizFramework.IBizFacade.AuthenticateAppUser(String strUserName)

at SupplierCommunicationPortal.scpLogin.btnLogin_Click(Object sender, EventArgs e) in D:\Applications\Supplier Communication Portal\Source\SupplierCommunicationPortal\SCPWeb\scpLogin.aspx.cs:line 78}

Aug 20, 2009 at 8:50 AM

Hi,

Do you access your business component using remoting? Is it a class library? found this threads that might be related:

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Aug 24, 2009 at 8:23 AM

Hi,

I found this blog: http://blogs.msdn.com/knewton/archive/2006/06/13/630006.aspx and seems to be describing your scenario. A quick workaround is to disable the Tracing in the config of the app that is hosting the remote object. Open the config and set the "TracingEnabled" property of the logging application block to false . I tested a simple remoting app with exceptionhandling-logging functionality and I repro your error. Then after applying the said workaround it now works fine.

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Aug 24, 2009 at 5:39 PM
Edited Aug 24, 2009 at 5:39 PM

It worked fine. Thank you so much!

Problem is, subsequent statements are not executed in catch block after execution of bool rethrow = ExceptionPolicy.HandleException(ex, "Log Only Policy");

my code -

 

 catch (Exception ex)
            {
                bool rethrow = ExceptionPolicy.HandleException(ex, "Log Only Policy");
                strResult = System.Configuration.ConfigurationManager.AppSettings["ErrPO"].ToString();
                if (rethrow)
                    strResult = System.Configuration.ConfigurationManager.AppSettings["ErrMsgLogFailed"].ToString();
            }

Aug 25, 2009 at 12:18 AM
Edited Aug 25, 2009 at 12:22 AM

Since the PostHandlingAction is set to none, the value of rethrow will be false.  It does proceed until line if(rethrow) but evaluates to false.  It will only result to true if you set the PostHandlingAction to either ThrowNewException or NotifyRethrow.

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Sep 11, 2009 at 6:30 PM

It worked perfect. Thank you so much

sorry for the late reply.