[Mono-bugs] [Bug 669351] New: System.InvalidOperationException is thrown instead of setting value to null

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu Feb 3 16:11:57 EST 2011


https://bugzilla.novell.com/show_bug.cgi?id=669351

https://bugzilla.novell.com/show_bug.cgi?id=669351#c0


           Summary: System.InvalidOperationException is thrown instead of
                    setting value to null
    Classification: Mono
           Product: Mono: Runtime
           Version: SVN
          Platform: Macintosh
        OS/Version: Mac OS X 10.6
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: generics
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: cthielen at gmail.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---


User-Agent:       Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; en-us)
AppleWebKit/533.19.4 (KHTML, like Gecko) Version/5.0.3 Safari/533.19.4

In the following piece of code, a LINQ query, the behavior under MSVS and Mono
differs:

HandleError(View = "NoConferenceError", ExceptionType =
typeof(ArgumentOutOfRangeException))]
        public ActionResult Show(string confName)
        {
            var conference = _conferenceRepository.Queryable.Where(x => x.Name
== confName).Single();

            if(conference == null) {
                throw new ArgumentOutOfRangeException("Conference name not
found:" + confName);
            }

            var model = Mapper.Map<Conference,
ConferenceShowModel>(conference);

            return View(model);
        }

In MSVS, 'conference' is set to null in the case of a non-matching confName,
leading the following if statement to evaluate to true, and throwing the
exception.

Under Mono, that LINQ line fails with the error:
System.InvalidOperationException , Operation is not valid due to the current
state of the object .

Here is the stack trace:
at System.Linq.Enumerable.Single<UCDMvcBootCamp.Core.Domain.Conference>
(System.Collections.Generic.IEnumerable`1<UCDMvcBootCamp.Core.Domain.Conference>,System.Func`2<UCDMvcBootCamp.Core.Domain.Conference,
bool>,System.Linq.Enumerable/Fallback) <0x00131>
at System.Linq.Enumerable.Single<UCDMvcBootCamp.Core.Domain.Conference>
(System.Collections.Generic.IEnumerable`1<UCDMvcBootCamp.Core.Domain.Conference>)
<0x00062>
at
NHibernate.Linq.Visitors.ImmediateResultsVisitor`1<UCDMvcBootCamp.Core.Domain.Conference>.HandleSingleCall
(System.Linq.Expressions.MethodCallExpression) <0x0003b>
at
NHibernate.Linq.Visitors.ImmediateResultsVisitor`1<UCDMvcBootCamp.Core.Domain.Conference>.VisitMethodCall
(System.Linq.Expressions.MethodCallExpression) <0x00245>
at NHibernate.Linq.Visitors.ExpressionVisitor.Visit
(System.Linq.Expressions.Expression) <IL 0x00131, 0x001cf>
at NHibernate.Linq.Visitors.NHibernateExpressionVisitor.Visit
(System.Linq.Expressions.Expression) <IL 0x00064, 0x00124>
at
NHibernate.Linq.Visitors.ImmediateResultsVisitor`1<UCDMvcBootCamp.Core.Domain.Conference>.GetResults
(System.Linq.Expressions.MethodCallExpression) <0x00017>
at NHibernate.Linq.Visitors.RootVisitor.HandleImmediateResultsCall
(System.Linq.Expressions.MethodCallExpression) <IL 0x0005c, 0x0016b>
at NHibernate.Linq.Visitors.RootVisitor.VisitMethodCall
(System.Linq.Expressions.MethodCallExpression) <IL 0x00259, 0x00438>
at NHibernate.Linq.Visitors.ExpressionVisitor.Visit
(System.Linq.Expressions.Expression) <IL 0x00131, 0x001cf>
at NHibernate.Linq.Visitors.NHibernateExpressionVisitor.Visit
(System.Linq.Expressions.Expression) <IL 0x00064, 0x00124>
at NHibernate.Linq.Visitors.NHibernateQueryTranslator.TranslateInternal
(System.Linq.Expressions.Expression) <IL 0x0001d, 0x00062>
at NHibernate.Linq.Visitors.NHibernateQueryTranslator.Translate
(System.Linq.Expressions.Expression,NHibernate.Linq.QueryOptions) <IL 0x00010,
0x00021>
at NHibernate.Linq.NHibernateQueryProvider.TranslateExpression
(System.Linq.Expressions.Expression) <IL 0x0009b, 0x00284>
at NHibernate.Linq.NHibernateQueryProvider.Execute
(System.Linq.Expressions.Expression) <IL 0x00002, 0x00017>
at
NHibernate.Linq.QueryProvider.System.Linq.IQueryProvider.Execute<UCDMvcBootCamp.Core.Domain.Conference>
(System.Linq.Expressions.Expression) <0x00019>
at System.Linq.Queryable.Single<UCDMvcBootCamp.Core.Domain.Conference>
(System.Linq.IQueryable`1<UCDMvcBootCamp.Core.Domain.Conference>) <0x00118>
at UCDMvcBootCamp.Controllers.ConferenceController.Show (string) [0x00022] in
/Users/cthielen/Projects/Work/UCDMvcBootCamp/trunk/UCDMvcBootCamp/Controllers/ConferenceController.cs:62
at (wrapper dynamic-method) object.lambda_method
(System.Runtime.CompilerServices.Closure,System.Web.Mvc.ControllerBase,object[])
<IL 0x0000e, 0x00055>
at System.Web.Mvc.ActionMethodDispatcher.Execute
(System.Web.Mvc.ControllerBase,object[]) [0x00000] in
/Users/cthielen/Projects/Work/mono/mcs/class/System.Web.Mvc2/System.Web.Mvc/ActionMethodDispatcher.cs:39
at System.Web.Mvc.ReflectedActionDescriptor.Execute
(System.Web.Mvc.ControllerContext,System.Collections.Generic.IDictionary`2<string,
object>) [0x00074] in
/Users/cthielen/Projects/Work/mono/mcs/class/System.Web.Mvc2/System.Web.Mvc/ReflectedActionDescriptor.cs:84
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod
(System.Web.Mvc.ControllerContext,System.Web.Mvc.ActionDescriptor,System.Collections.Generic.IDictionary`2<string,
object>) [0x00000] in
/Users/cthielen/Projects/Work/mono/mcs/class/System.Web.Mvc2/System.Web.Mvc/ControllerActionInvoker.cs:190
at
System.Web.Mvc.ControllerActionInvoker/<InvokeActionMethodWithFilters>c__AnonStorey36.<>m__45
() [0x00000] in
/Users/cthielen/Projects/Work/mono/mcs/class/System.Web.Mvc2/System.Web.Mvc/ControllerActionInvoker.cs:232
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter
(System.Web.Mvc.IActionFilter,System.Web.Mvc.ActionExecutingContext,System.Func`1<System.Web.Mvc.ActionExecutedContext>)
[0x00033] in
/Users/cthielen/Projects/Work/mono/mcs/class/System.Web.Mvc2/System.Web.Mvc/ControllerActionInvoker.cs:206

Reproducible: Always

Steps to Reproduce:
1. Use the code above in some valid example
2. See the wrong exception being thrown
Actual Results:  
Threw System.InvalidOperationException.

Expected Results:  
conference to evaluate to null, as it does on MSVS

-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list