locked
Validation works only when not debugging RRS feed

  • Question

  • User-1395768221 posted

    Hi - just starting with DD - following some of the videos and tutorials.

    I've got the following override method:

        [MetadataType(typeof(userMetadata))]
        public partial class user
        {
            partial void Onusr_salChanging(string value)
            {
                if (value != null && value.Substring(0, 1) != value.Substring(0, 1).ToUpper())
                {
                    throw new ValidationException("Titles must start with an upper case letter!");
                }
            }
        }

    If I run with debugging, I get the following error:

    System.ComponentModel.DataAnnotations.ValidationException was unhandled by user code
      Message=Titles must start with an upper case letter!
      Source=App_Code.ikzvtub3
      StackTrace:
           at tester2Model.user.Onusr_salChanging(String value) in c:\Source\DotNet_Ver40\Dynamic2\App_Code\AutoMetaData.cs:line 397
           at tester2Model.user.set_usr_sal(String value) in c:\Source\DotNet_Ver40\Dynamic2\App_Code\Model.Designer.cs:line 1889
      InnerException: 

    It works fine from "run in browser" but not if I run with debugging.  I'm not sure if this is a debugger setting or something else - I've searched the forum and found similar postings, but no solution.

    Sunday, January 23, 2011 12:12 PM

All replies

  • User-330204900 posted

    I think that normal [:)] in debug mode it does tend to catch exceptions then. 

    Sunday, January 23, 2011 12:24 PM
  • User-1395768221 posted

    Thanks for the reply.

    I was basically following the example here:

    http://www.asp.net/aspnet-in-net-35-sp1/videos/how-to-implement-custom-field-validation-with-imperative-logic-in-vb-or-c

    The presenter ran the example in debugger mode - he didn't get the exception - his validation code handled the exception as you would expect.

    That's why I'm wondering if it's not a specific visual studio debugger setting (I'm running VS2010 express)?

    Sunday, January 23, 2011 1:06 PM
  • User-330204900 posted

    I'm not sure I get the same issue hit and miss [:(] 

    Sunday, January 23, 2011 1:30 PM
  • User1957418580 posted

    I've seen this issue with Visual Studio on 64-bit machines.  Have you tried pointing it to IIS Express?

    Is your machine 64 bit?  I don't have VS Express to test on here.

    Wednesday, February 16, 2011 12:00 PM