Bug 2429 - DataContext.SubmitChanges throws InvalidCastException with Npgsql 4.0.0.0
Summary: DataContext.SubmitChanges throws InvalidCastException with Npgsql 4.0.0.0
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Data (show other bugs)
Version: 2.10.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2011-12-08 16:59 UTC by Cédric Belin
Modified: 2015-01-24 12:11 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 2429 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
NEW

Description Cédric Belin 2011-12-08 16:59:32 UTC
I have an ASP.NET application (4.0 profile) which uses LINQ to SQL with PostgreSQL.

Every time that I use the System.Data.Linq.DataContext.SubmitChanges method, an InvalidCastException is raised (regardless of the code).

If I use the assembly downloaded on Npgsql site (version 2.0.11.92 for .NET 4.0) instead of the one provided by Mono (version 4.0.0.0), everything works like a charm.

At first glance, there is a bug in the Npgsql assembly supplied in the Mono stack.

Here is a typical stack trace :

Sys.WebForms.PageRequestManagerServerErrorException: Sys.WebForms.PageRequestManagerServerErrorException: System.Web.HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidCastException: Cannot cast from source type to destination type.
  at System.Data.Linq.DataContext.SubmitChanges (ConflictMode failureMode) [0x00000] in <filename unknown>:0 
  at System.Data.Linq.DataContext.SubmitChanges () [0x00000] in <filename unknown>:0 
  at JypoEditions.Data.Shipping.SetDefault (JypoEditions.Data.Shipping entity) [0x0004f] in /Users/Cedric/Repository/Web/JypoEditions/Sources/Shipping.cs:100 
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 
  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <filename unknown>:0 
  at System.Web.UI.WebControls.ObjectDataSourceView.InvokeMethod (System.Reflection.MethodInfo method, IOrderedDictionary paramValues) [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at System.Web.UI.Page.ProcessException (System.Exception e) [0x00000] in <filename unknown>:0 
  at System.Web.UI.Page.ProcessRequest (System.Web.HttpContext context) [0x00000] in <filename unknown>:0 
  at System.Web.HttpApplication+<Pipeline>c__Iterator6.MoveNext () [0x00000] in <filename unknown>:0 
  at System.Web.HttpApplication.Tick () [0x00000] in <filename unknown>:0