Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > BOOK: Professional ASP.NET MVC 2
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional ASP.NET MVC 2
This is the forum to discuss the Wrox book Professional ASP.NET MVC 2 by Jon Galloway, Scott Hanselman, Phil Haack, Scott Guthrie, Rob Conery; ISBN: Professional ASP.NET MVC 2
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional ASP.NET MVC 2 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 26th, 2010, 10:51 AM
Registered User
 
Join Date: Oct 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Arrow Problem need help(!!!) ConstraintException was unhandled bt user code

in this book Professional ASP.NET MVC 2

There are 2 partial classes:
Code:
    public partial class Dinner :EntityObject { 

for example title property 
 [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.String Title
        {
            get
            {
                return _Title;
            }
            set
            {
                OnTitleChanging(value);
                ReportPropertyChanging("Title");
                _Title = StructuralObject.SetValidValue(value, false);// here throws Exception * 
                ReportPropertyChanged("Title");
                OnTitleChanged();
            }
        }
            
        }
Code:
[MetadataType(typeof(Dinner_Validation))]
    public partial class Dinner {
    }

    public class Dinner_Validation {
        [Required(ErrorMessage = "Title is required")]
        [StringLength(50, ErrorMessage = "Title may not be longer than 50 characters")]
        public string Title { get; set; }
        [Required(ErrorMessage = "Description is require")]
        [StringLength(265, ErrorMessage = "Description must be 256 characters or less")]
        public string Description { get; set; }
        [Required(ErrorMessage = "Address is required")]
        public string Address { get; set; }
        [Required(ErrorMessage = "Country is required")]
        public string Country { get; set; }
        [Required(ErrorMessage = "Phone# is required")]
        public string ContactPhone { get; set; }
        [Required(ErrorMessage = "EventDate is required")]
        public DateTime EventDate { get; set; }
        [Required(ErrorMessage = "HostedBy is required")]
        public string HostedBy { get; set; }
        [Required(ErrorMessage = "Latitude is required")]
        public double Latitude { get; set; }
        [Required(ErrorMessage = "Longitude is required")]
        public double Longitude { get; set; }
    }
* - ConstraintException was unhandled but user code,This property cannot be set to a null value.

in spite of there is validators on each control

How do I solve this problem?
  #2 (permalink)  
Old October 26th, 2010, 11:23 AM
Friend of Wrox
Points: 539, Level: 8
Points: 539, Level: 8 Points: 539, Level: 8 Points: 539, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2010
Location: Seattle
Posts: 106
Thanks: 1
Thanked 17 Times in 17 Posts
Default

Maybe its not really a problem for this excercise. Are you running the app (Ctrl+F5) or are you debugging (F5)? When you F5 to debug, debugger will stop on warnings.
  #3 (permalink)  
Old October 26th, 2010, 12:57 PM
Registered User
 
Join Date: Oct 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by flyinhawaiian View Post
Maybe its not really a problem for this excercise. Are you running the app (Ctrl+F5) or are you debugging (F5)? When you F5 to debug, debugger will stop on warnings.
No, I am not running the app wit Ctrl+F5(yes, with this works fine)
why is it problem with F5?

No There is not any warnings When I use F5, only throws Exception as I said in my first post
  #4 (permalink)  
Old October 26th, 2010, 01:52 PM
Friend of Wrox
Points: 539, Level: 8
Points: 539, Level: 8 Points: 539, Level: 8 Points: 539, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2010
Location: Seattle
Posts: 106
Thanks: 1
Thanked 17 Times in 17 Posts
Default

I believe the message is a warning (yellow triangle with "!"). A real error will halt execution (when doing Ctrl+F5 run w/no debug).

How to handle? A couple of options.
1. Leave it alone for now. There are enough issues you're going to deal with in NerdDinner.

2. Relax the constraint.

3. Turn off the warning. It's an option under Tools / Options / Debugging.

4. Handle the exception. You'll find there not much you can do with this (in this case) other than have an empty handler to make the debugger happy. In addition there will be lot's of other unhandled exceptions. Do you really want to deal with them all right now?

5. Make the column nullable in the database. Redo the Dinner entity. Then Let MVC do the validations. Works, but not a good idea.

Hope this helps.
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
System.NullReferenceException was unhandled by user code - Chapter 8 dtmmaxx BOOK: Beginning ASP.NET 4 : in C# and VB 10 September 1st, 2011 05:51 PM
ConstraintException was unhandled by user code jcooper0 BOOK: Professional ASP.NET MVC 2 8 February 16th, 2011 09:32 AM
HttpCompileException was unhandled by user code. error CS0246 fh84 BOOK: ASP.NET MVC Website Programming Problem Design Solution ISBN: 9780470410950 4 October 25th, 2010 12:49 PM
TargetInvocationException was unhandled by user code MattHoff BOOK: ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solutio 2 October 13th, 2010 11:38 AM
How To sort Gridview Column bt Time Only rao965 ASP.NET 2.0 Professional 0 May 22nd, 2009 04:30 AM



All times are GMT -4. The time now is 07:59 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.