Groups | Blog | Home
all groups > dotnet distributed apps > october 2003 >

dotnet distributed apps : ExceptionManagement Application Blocks Problem


Ian
10/3/2003 9:19:59 AM
I'm trying to create a custom publisher and I want to store the data in a
sql table and I can't find any examples any where on how to use a database
instead of (event log, text file, xml file or WMI). If someone could direct
me in the right direction. For example I am storing the connection string in
the publisher and I don't know how to retrieve the information from the
app.config file.

Also I tried running the quickstart that comes with the download of the
ExceptionManagement Application Block and it keeps on getting errors trying
to create the custom publisher. Now I haven't changed one piece of code in
the quickstart so I'm getting a little skeptical about this specific block.

I'm getting the error in app.config file with the following line.

<configSections>

<section name="exceptionManagement"
type="Microsoft.ApplicationBlocks.ExceptionManagement.ExceptionManagerSectio
nHandler,Microsoft.ApplicationBlocks.ExceptionManagement" />

</configSections>

And the error message is.

{System.Configuration.ConfigurationException}

[System.Configuration.ConfigurationException]:
{System.Configuration.ConfigurationException}

HelpLink: Nothing

InnerException: Nothing

Message: "Could not create
Microsoft.ApplicationBlocks.ExceptionManagement.ExceptionManagerSectionHandl
er,Microsoft.ApplicationBlocks.ExceptionManagement"

Source: "System"

StackTrace: " at System.Configuration.ConfigurationRecord.GetFactory(String
configKey)

at System.Configuration.ConfigurationRecord.Evaluate(String configKey)

at System.Configuration.ConfigurationRecord.ResolveConfig(String configKey)

at System.Configuration.ConfigurationRecord.GetConfig(String configKey)

at
System.Configuration.DefaultConfigurationSystem.System.Configuration.IConfig
urationSystem.GetConfig(String configKey)

at System.Configuration.ConfigurationSettings.GetConfig(String sectionName)

at
Microsoft.ApplicationBlocks.ExceptionManagement.ExceptionManager.Publish(Exc
eption exception, NameValueCollection additionalInfo)"

TargetSite: {System.Reflection.RuntimeMethodInfo}



Thanks

lukezhan NO[at]SPAM online.microsoft.com
10/6/2003 6:43:20 AM
Hi Lan,

Let's refer to theExceptionXMLPublicer in quickstart sample to explain how
to log the information in a SQL database:

Public Sub Publish(ByVal ExceptionInfo As XmlDocument, ByVal
ConfigSettings As NameValueCollection) Implements
IExceptionXmlPublisher.Publish
Dim filename As String

If Not ConfigSettings Is Nothing Then
filename = ConfigSettings("fileName")
Else
filename = "C:\ErrorLog.xml"
End If

Dim fs As FileStream = File.Open(filename, FileMode.Create,
FileAccess.ReadWrite)
Dim writer As StreamWriter = New StreamWriter(fs)

writer.Write(ExceptionInfo.OuterXml)
writer.Close()
fs.Close()

End Sub

As you said, you can save the connection string in config file Publicer:

<exceptionManagement mode="on">

<publisher ... ConnectString="server=localhost;uid=sa;"/>
</exceptionManagement>

In your customized publicer, you can get the string with:

ConfigSettings("ConnectString")

It is read and pass in your Publicer by ExceptionManager.

After get this string, you can create a SQLConnection and a SQLCommand
object to execute a Inert statement.

Regarding the error on executing quickstart sample, I suggest you may first
unstall the application block and reinstall in it different folder to see
if it can work.

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Ian
10/6/2003 9:06:41 AM
thanks for the info.

[quoted text, click to view]

AddThis Social Bookmark Button