entlib3.1 logging problem

Topics: Logging Application Block
Sep 18, 2007 at 8:00 AM
i,

I keep getting an exception when I extended logging application block of enlib 3.1 to support remoting logging.

I just wrote a proxy class to call a remoted method that only to executed "Logger.Write("some word")" in server!
My service is host in IIS 6.0 .
is it a issue?

as reply:
I want to know wether enlib 3.1 can be extended to support remoting logging.
or who can give me some solution !

thanks



Proxy class:

public class LoggerProxy :ILogger
{

public LoggerProxy(string remoteAddress)
{
_remoteAddress = remoteAddress;
}

private string _remoteAddress;

public string RemoteAddress
{
get { return _remoteAddress; }
set { _remoteAddress = value; }
}

private ILogger Proxy
{
get
{
return (ILogger)Activator.GetObject(typeof(ILogger), UrlHelper.GetRemotingUrl(_remoteAddress));
}
}

#region ILogger Members

public void Write(LogEntry log)
{
Proxy.Write(log);
}

public void Write(string message)
{
Proxy.Write(message);
}

#endregion

actual class(executed in service):

public class LoggerRemotingService : MarshalByRefObject, ILogger
{
#region ILogger Members

public void Write(LogEntry log)
{
Logger.Write(log);
}

public void Write(string message)
{
Logger.Write(message);
}

#endregion
}



The error details as blew:

System.Reflection.TargetInvocationException was unhandled
Message="Exception has been thrown by the target of an invocation."
Source="mscorlib"
StackTrace:
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 NCS.IConnect.Logging.ILogger.Write(String message)
at NCS.IConnect.Logging.LoggerProxy.Write(String message) in D:\MYProject\iConnect\SourceCode\Logging\LoggerProxy.cs:line 47
at NCS.IConnect.Logging.RemotingTraceListener.Write(String message) in D:\MYProject\iConnect\SourceCode\Logging\RemotingTraceListener.cs:line 43
at winloggingtest.Program.Main() in E:\vs.net2005project\winloggingtest\winloggingtest\Program.cs:line 23
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
Sep 18, 2007 at 12:25 PM
This is a rather non-specific remoting error. Can you get information about the actual error that occurred (probably from the InnerException property of the exception you can catch at winloggingtest.Program.Main())? I also suggest you temporarily comment out the actual Logger calls in your logger service to remove factors in your problem.

Can you use the Msmq logging service instead of creating this remoting solution?

Fernando
Sep 19, 2007 at 4:25 AM
thanks for you reply!

The internalexception's details as following:
System.InvaildCastException:Specified cast is not valid.
Data:{System.Collections.ListDictionaryInternal}
HelpLink: NULL
Source:"mscorlib"
StackSource:at System.Runtime.Remoting.Messaging.LogicalCallContext..ctor(SerializationInfo info, StreamingContext context)
TargetSite:{Void .ctor(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)}


I got the exception when finished "Logger.Write("some word")" and being out of method
public void Write(string message)
{
Logger.Write(message);
}
Sep 19, 2007 at 12:05 PM
Hi,

Try commenting out the logger call, to determine if it's doing something that causes the problem even if it's already finished by the time the error occurs. Also try to get a stack trace from the internal exception.

Fernando