Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 888341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:22:54+00:00 2026-05-15T13:22:54+00:00

So I’ve got this exception defined, protected constructors, static constructor methods (so all the

  • 0

So I’ve got this exception defined, protected constructors, static constructor methods (so all the exceptions are generated with the same formatting and I don’t have to fight in the constructors. Anyway, this is besides the point… (not my issue? let’s leave that alone k?)

public class ValidationException : Exception
{
   // Constructors
   public static ValidationException Create(IEnumerable<string> errors)
   {
      // yadda, yadda, yadda, build exception message, pass in errors, configure, shabang...
      return vex; // vex is the created exception
   }
}

Then I have the following code as part of an NHibernate PreInsertEventListener.

IDictionary<string, IEnumerable<string>> validationErrors;
if (TryValidateObject(obj, out validationErrors)) return;

throw ValidationException.Create(validationErrors);

Then in my implementation i have this:

try
{
   Save();
}
catch (ValidationException)
{
   UserMessage.CreateMessage("A Validation error has occured. Please contact your system administrator / software support.").Show();
}

The save function basically does all my final manipulation in NHibernate and executes Flush() on the data session.

So basically as an overview:

  1. Save() is called.
  2. Flush() is called in NHibernate
  3. NHibernate’s pipeline is executed
  4. My PreInsertEventListener event is called.
  5. ValidationException.Create(...) is called which returns a ValidationException. This is then thrown from the PreInsertEventListener

Now here’s the real doosey. The expected behaviour is that the catch block fires, and catches my ValidationException, prompting my user message dialog to show up.

But what actually happens is that vstudio & my app in debug hang for about 1 minute. 100% unresponsive, window signals ignored, windows ready to kick the process in the butt, then it finally unsticks and tells me an “Unhandled ValidationException was thrown”, at the exact line that im throwing my exception. So somehow this isn’t getting caught.

When i run this outside of the debugger, the app insta-fails.

Am i missing something? This all should be executed from the same thread, the call stack is pretty danm clear:

> MyApp.Core.dll!MyApp.Core.Validation.ValidationHelper.DoValidateObject(object obj = {MyApp.Data.Entities.Administration.Career}) Line 153 C#
  MyApp.Data.Entities.dll!MyApp.Data.Entities.Entity.Validate(out System.Collections.Generic.IDictionary> validationErrors = null, bool throwExceptions = true) Line 73 + 0xa bytes C#
  MyApp.Data.dll!MyApp.Data.NHibernate.EntityValidateListener.OnPreInsert(NHibernate.Event.PreInsertEvent event = {NHibernate.Event.PreInsertEvent}) Line 23 + 0x30 bytes C#
  NHibernate.dll!NHibernate.Action.EntityInsertAction.PreInsert() Line 151 + 0x42 bytes C#
  NHibernate.dll!NHibernate.Action.EntityInsertAction.Execute() Line 44 + 0xd bytes C#
  NHibernate.dll!NHibernate.Engine.ActionQueue.Execute(NHibernate.Action.IExecutable executable = {EntityInsertAction[MyApp.Data.Entities.Administration.Career#24cda829-e829-4228-997f-55ff890d6eec]}) Line 130 + 0x37 bytes C#
  NHibernate.dll!NHibernate.Engine.ActionQueue.ExecuteActions(System.Collections.IList list = Count = 1) Line 113 + 0x10 bytes C#
  NHibernate.dll!NHibernate.Engine.ActionQueue.ExecuteActions() Line 146 + 0x13 bytes C#
  NHibernate.dll!NHibernate.Event.Default.AbstractFlushingEventListener.PerformExecutions(NHibernate.Event.IEventSource session = {NHibernate.Impl.SessionImpl}) Line 240 + 0x3d bytes C#
  NHibernate.dll!NHibernate.Event.Default.DefaultFlushEventListener.OnFlush(NHibernate.Event.FlushEvent event = {NHibernate.Event.FlushEvent}) Line 19 + 0x1b bytes C#
  NHibernate.dll!NHibernate.Impl.SessionImpl.Flush() Line 1187 + 0x92 bytes C#
  MyApp.Data.dll!MyApp.Data.AbstractDataSession.Flush() Line 57 + 0x36 bytes C#
  MyApp.UIFramework.dll!MyApp.UIFramework.ViewModel.EntitiesViewModel.Save() Line 110 + 0x2c bytes C#
  ManagerWPF.exe!ManagerWPF.Modules.Careers.ViewModels.CareersViewModel.HandleSave() Line 274 + 0x11 bytes C#
  ManagerWPF.exe!ManagerWPF.Modules.Careers.ViewModels.CareersViewModel.get_SaveCommand.AnonymousMethod(object x = null) Line 263 + 0xa bytes C#
  MyApp.UIFramework.dll!MyApp.UIFramework.Commands.DelegateCommand.Execute(object parameter = null) Line 50 + 0x24 bytes C#
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T13:22:54+00:00Added an answer on May 15, 2026 at 1:22 pm

    If you are certain that all happens on the same thread (this is what it looks like from your call stack) then it could be a namespace conflict, too.

    Are the ValidationException types being thrown and the one that should be catch identical, i.e. in the same namespace? Seems that NHibernate already defines a ValidationException and you also define your own ValidationException.

    To fix such a problem you have several options:

    • Get rid of your own custom exception and use the one provided by the framework
    • Rename your exception class
    • Use fully qualified names, e.g. MyApp.Exceptions.ValidationException
    • Use an alias name when importing a namespace: using MyEx = MyApp.Exceptions;
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a text area in my form which accepts all possible characters from
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.