Hi David...
Here is a detailed description of my projects...
In Main project I have a class that impliments BaseApplicationException
[Serializable]
public class CKException : BaseApplicationException
{
public CKException(string p_sVillubod, Exception p_exVilla,string
p_sUtgafunumer, int p_nVerklidurNumer,string p_sStarfsmadurNumer, string
p_sStarfsmadurNafn) : base(p_sVillubod, p_exVilla)
{
System.Reflection.PropertyInfo pi =
p_exVilla.GetType().GetProperty("Numfber");
}
// protected constructor to de-seralize state data
protected CKerfisvillaException(SerializationInfo info, StreamingContext
context) : base (info, context)
{
// Initialize state
//some code
}
// override GetObjectData to serialize state data
[SecurityPermission(SecurityAction.Demand, SerializationFormatter =
true)]
public override void GetObjectData(SerializationInfo info,
StreamingContext context)
{
// Serialize this class' state and then call the base class
GetObjectData
...some code
base.GetObjectData(info, context);
}
}
}
also I have a class in this project that impliments IExceptionPublisher
public class CDSPublisher : IExceptionPublisher
{
void IExceptionPublisher.Publish(Exception exception,
NameValueCollection additionalInfo, NameValueCollectionconfigSettings)
{...}
}
Third Exception klass is called CVilla and it handles calls to function in
the CKException and CDSPublisher
public sealed class CVilla
{
// init some variables...
private CVilla() {}
private static void writeException(string p_sException,Exception
p_exException)
{
...
CKException exK = new CKException(...);
ExceptionManager.Publish(exKerfisvilla);
}
...
}
All the forms in the main project inherit a class that handles any
exception
handling and if an exception is thrown, then
the parent class handles the exception. The forms call a function in the
DB
project but if an exeption is thrown in that project, the
exception is not catched in the Main project? CVilla class is never ref.
in
the db project and there is no exception handling there!
I can use Reflection to use the CVilla class but it must be another
smarter
way to handle exception in large solutions. I want to be able
to catch all errors in one place.
here is the app.config ..
<configuration>
<configSections>
<section name="exceptionManagement"
type="Microsoft.ApplicationBlocks.ExceptionManagement.ExceptionManagerSectio
nHandler,Microsoft.ApplicationBlocks.ExceptionManagement" />
</configSections>
<exceptionManagement mode="on">
<publisher mode="on" assembly="kerfi" type="kerfi.CDSPublisher" />
</exceptionManagement>
</configuration>
Hope this is what you are looking for....
David Levine said:
Where are you catching the exception? Where are you writing to the
management block? These two lines of code don't show me anything that I can
evaluate.
no problem....
I have 2 project, one that is the main project and one database
project.
In the main project I have a class that impliments the IExceptionPublisher
and there I the write the Publish function? The main project ref. the
database project.
My problem is when an error is thrown in database project, the
exception
class, in main project, doesn't catch the error? Works in debug mode but
not in release mode???
Exemple:
public void MyFunction()
{
MyDataAdapter.Update(MyDataSet.MyDataTable); -- thows an
error
MyDataSet.MyDataTable.AcceptChanges();
}
When I try to run this function in the database project, an error is
thrown
because I cant insert a NULL in one field.
What I dont understand is why its works fine in Debug but not in Release??
Do I have to change some settings?
Please let me know if you need more information
Very best regards
Palli
Can you provide a short sample which demonstrates the problem? I've
not
had
any problems with it myself.
Hi
I have a problem with the
Microsoft.ApplicationBlocks.ExceptionManagement?
I
can't get it to work in RELEASE mode? If I run the project in debug
mode
the block works fine but when I run the exe file it doesn't catch
any
errors?
Does anyone know what my problem might be?
Regards
Palli