Join 34,000+ subscribers and receive articles from our
blog about software quality, testing, QA and security.

Exception loading configuration


#1

Hi,
I’m testing SmartInspect in a windows service written in VB.NET (VS2005)
In OnStart() method, I have the following

SiAuto.Si.LoadConfiguration(sicFile) logConfigRefreshTimer = New ConfigurationTimer(SiAuto.Si, sicFile, 10000)

my “sicFile” contains:

AppName = GPEC Connections = file(append="true", filename="$apppath$\gpec.sil", maxparts="7", rotate="daily"), text(append="true", filename="$apppath$\gpec.log", maxparts="7", rotate="daily", pattern="%timestamp% - %level,-7% - %title%", indent="true"), pipe(reconnect="true", reconnect.interval="1") DefaultLevel = Debug Enabled = True Level = Debug

If I have SmartInspect Console up and running, everything works fine
But when I have no console running, I catch the following exception

[quote]Gurock.SmartInspect.ProtocolException: Impossibile trovare il file specificato. (Eccezione da HRESULT: 0x80070002)
in Gurock.SmartInspect.Protocol.HandleException(String message)
in Gurock.SmartInspect.Protocol.ImplConnect()
in Gurock.SmartInspect.Protocol.Connect()
in Gurock.SmartInspect.SmartInspect.Connect()

protocol name: pipe
protocol options: async.enabled=“false”, async.clearondisconnect=“false”, async.queue=“2048”, async.throttle=“true”, backlog.enabled=“false”, backlog.flushon=“error”, backlog.keepopen=“false”, backlog.queue=“2048”, level=“debug”, caption=“pipe”, reconnect=“true”, reconnect.interval=“1000”, pipename=“smartinspect”
[/quote]

I understand this is due to the fact that the pipe is not open, am I right?

thank
stefano


#2

Hello Stefano,

do you catch the exception in the SiAuto.Si.Error event handler or directly in a try…catch block surrounding the call to the ConfigurationTimer constructor? The ConfigurationTimer constructor shouldn’t throw an exception.

Yes. If you are registered to the Error event, then this is the normal behavior. The pipe connection cannot connect to the Console and throws an exception which is then passed to the Error event handlers. Note that this error does not affect the other connections. The file connections work even if the pipe connection cannot be established.


#3

yes, I catch the exception in SiAuto.Si.Error event handler.

Actually I get two exception (with the same “reason”), one for the LoadConfiguration and the other for the Configuration constructor.

I’m glad to hear this is the normal behavior (I just miss it in my previous tests)

thanks
stefano


#4

Hi

I modified my SmartInspectEventHandler() to intercept and discard Protocol exception from the pipe protocol

        If (TypeOf Args.Exception Is ProtocolException) Then
            Dim pe As ProtocolException = Args.Exception
            If (pe.ProtocolName = "pipe") Then
                Exit Sub
            End If
        End If

the code snippet above will discard every exception from the pipe protocol.
Is there a way to discard pipe not found only?

thanks
stefano


#5

You can actually omit the manual call to LoadConfiguration as the ConfigurationTimer constructor also calls LoadConfiguration once before spawning the watch thread. Your extra LoadConfiguration call is the reason you get the exception twice (because you are effectively loading the configuration file twice).

There’s currently no reliable way to do this. Inner exceptions are not passed to the Error event handlers, so checking for the protocol name and ignoring all exceptions of this particular protocol is currently the only option.

Regards,
Tobias


#6

thanks

stefano