Hi All,
I am trying to create a simple DBException Class which I want to use in
different apps.
Here is what I am doing:
1. I Created a VB Class
Imports Microsoft.ApplicationBlocks.ExceptionManagement
Imports System.Data.SqlClient
Public Class DBExceptionPublisher
Implements IExceptionPublisher
Private SQL_CONNECTION_STRING As String = _
"User Id=sqamar;" & _
"Password=password;" & _
"Server=trd-11982;" & _
"DataBase=NX20;"
Public Sub Publish(ByVal exception As System.Exception, _
ByVal additionalInfo As System.Collections.Specialized.NameValueCollection ,
_
ByVal configSettings As System.Collections.Specialized.NameValueCollection )
_
Implements
Microsoft.ApplicationBlocks.ExceptionManagement.IE xceptionPublisher.Publish
Dim strConn As String = SQL_CONNECTION_STRING
Dim scnnFTTP As New SqlConnection(strConn)
Dim scmd As New SqlCommand("spTestTable", scnnFTTP)
Try
scnnFTTP.Open()
scmd.CommandType = CommandType.StoredProcedure
With scmd.Parameters
..Add(New SqlParameter("@paramin", SqlDbType.VarChar)).Value = "Hello String"
End With
Dim myReader As SqlDataReader = scmd.ExecuteReader()
Catch expSQL As SqlException
MessageBox.Show(expSQL.Message())
End Try
End Sub
End Class
2. Created a app.config file
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="exceptionManagement"
type="Microsoft.ApplicationBlocks.ExceptionManagem ent.ExceptionManagerSectio
nHandler,Microsoft.ApplicationBlocks.ExceptionMana gement" />
</configSections>
<exceptionManagement mode="on">
<publisher assembly="VB_App_Test" type="VB_App_Test.DBExceptionPublisher" />
</exceptionManagement>
</configuration>
3. In my VB Form I did:
Try
Dim x As Integer
Dim y As Integer
y = 0
x = 1 / y
Catch ex As Exception
ExceptionManager.Publish(ex)
End Try
This works fine but when I create another project and reference this dll it
gives me an error:
Argument not specified for parameter 'additionalInfo' of 'Public Overridable
NotOverridable Sub Publish(exception As System.Exception, additionalInfo As
System.Collections.Specialized.NameValueCollection , configSettings As
System.Collections.Specialized.NameValueCollection )'.
C:\Documents and Settings\slqamar\My Documents\Visual Studio
Projects\ExceptionManagerTestApp\Form1.vb(65): Argument not specified for
parameter 'configSettings' of 'Public Overridable NotOverridable Sub
Publish(exception As System.Exception, additionalInfo As
System.Collections.Specialized.NameValueCollection , configSettings As
System.Collections.Specialized.NameValueCollection )'.
PLease can someone tell me what I am doing wrong.
Thx
Sal