From: Danny G. <da...@ab...> - 2011-03-24 04:59:52
|
I was chasing this problem (http://tracker.firebirdsql.org/browse/DNET-327) and was about to post to the list to try to find a solution when I found this http://blog.cincura.net/232192-ado-net-provider-2-6-0-for-firebird-released/ and in one of the comments (DEC 20, 2010) Jiri said: "I was testing it with Mono 2.8.1 and 2.8.0 on Slackware, but maybe Mac version is missing some charsets. Simply comment out the line in FirebirdSql.Data.Common.Charset." That tipped me off to an easy workaround so I started putting the #if (!MONO) around Charsets until I stopped getting the error. This solved my problem (for now, until I put my code on a different platform or version of my platform), but don't see this as a good solution for the Firebird provider project. In all I had to eliminate 15 character sets from that type initializer to get it to work, and it took the better part of a day to track down the root cause and do that elimination process. So I'm posting to try to get an understanding of how this part of the code could work better, and contribute an enhancement. I'm not all that familiar with how the different OS, runtime and DB platforms deal with character sets, so I may be guilty of wishful thinking...so my question was: Is there a way to detect the character sets supported by the platform? We could then merge that with the character sets supported by Firebird and this provider and prevent this problem from reoccurring. I tried a very straightforward approach using Encoding.GetEncodings and trying to search that list to eliminate unsupported encodings before problems were encountered, but that didn't work because accessing the EncodingInfo data (as returned from that method) throws an exception if the CodePage isn't supported, apparently because it is trying to initialize it's internal encoding when accessed*. So I mangled it to the less elegant version that I've attached. I've tested it here and it solves my problem without conditional compilation or commenting out unsupported encodings. Look for "InitializeSupportedCharsets". The old version is present, but commented out. *This doesn't happen on MS.NET. My environments are: danno@puma:~/dev/firebird$ mono --version Mono JIT compiler version 2.6.7 (Debian 2.6.7-5ubuntu1~dhx1) Copyright (C) 2002-2010 Novell, Inc and Contributors. www.mono-project.com TLS: __thread GC: Included Boehm (with typed GC and Parallel Mark) SIGSEGV: altstack Notifications: epoll Architecture: amd64 Disabled: none Firebird.NET Provider 2.6.0 (compiled on Ubuntu Desktop 10.04.2) testing on Ubuntu Server 10.04.2 (Lucid Lynx) ...and... Windows.NET 2.0, Firebird.NET Provider 2.5.1 from download running on Windows XP (development and unit test with VS.NET 2005). Also, one side note: when compiling 2.6.0 without the ENTITY_FRAMEWORK directive, I got errors on Entity.SSDLToFB.cs (added sometime after 2.5.2). Adding #if (NET_35 && ENTITY_FRAMEWORK) condition solved that problem. Is that missing conditional an oversight, or should I not need that conditional and is there something else wrong with my setup? Cheers, Danny -- Danny Gorton II Co-founder Absolute Power and Control, LLC www.absolutepowerandcontrol.com |