|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Enterprise Library and PostgreSQL (Npgsql)posted in the pgFoundry forums as well, in hopes that someone can answer these. I'm using the Npgsql .Net data provider for PostgreSQL (http://pgfoundry.org/projects/npgsql/). 1) Has anyone already added support for this provider to the Enterprise Library? If so, where can I get it? If not, how would I go about it? 2) I am using the Enterprise Library's ExceptionHandling. When my Npgsql connection fails, the exception handler in ExceptionHandling blows up. I don't really know if this is a bug that should be attributed to the Enterprise Library or to the Npgsql. Has anyone run into this before? I've worked around it for now by modifying ExceptionFormatter and putting a try..catch around "value = property.GetValue(e, null);" (around line 175). This works, but I'm far from certain this is the right way to do it. Thanks! Brad. Hello Brad,
Thank you for posting in the MSDN newsgroup. From your description, you're using the enterprise library to develop your .net application and when dealing with the PostgreSQL database, you're wondering how to integrated the npgsql provider with enterprise library's DAAB. Also, you're getting some other exceptions when the connection to postgresql fails, correct? Based on my research, the npgsql managed provider for postgreSQL database has only provided .net framework 1.1 based version. Therefore, I think your application is also developing under .net framework 1.1 and the enterprise library is of version 1.0(2.0 is specfic to .net framework 2.0), correct? In the enterprise library 1.0, the built-in database provdiers include SQL, Oracle, DB2 database providers. As for postgreSQL, if you want to integraed it into the enterprise library daab framework, you need to create a custom database provider. This require the following work: =========== Create a new command wrapper that derives from DBCommandWrapper. Create a new database class that derives from Database. Additionally, if you want your client code to remain database-agnostic, you may need to write additional code to perform such tasks as type conversion. =========== You can find the "Adding a New Database Provider" topic in the documentation of enterprise library 1.0(the latest version is 2005 June). As for the second problem you mentioned, what's the detailed behavior you met when the Npgsql connection fails? Is the actual exception instance thrown out to front UI? Based on my understanding, the exception handling block let us define some exception management policy which can control how to process when encountering some certain types of exception. What's the underlying exception type it thrown when Npgsql connection fails(I think it should be a Npgsql specific exception type) and have you explicitly configured any policy for it(such as None, Notify and rethrow, or replacing with new type). Hope this helps. Sincerely, Steven Cheng Microsoft MSDN Online Support Lead ================================================== Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif ications. Note: The MSDN Managed Newsgroup support offering is for non-urgent issues where an initial response from the community or a Microsoft Support Engineer within 1 business day is acceptable. Please note that each follow up response may take approximately 2 business days as the support professional working with you may need further investigation to reach the most efficient resolution. The offering is not appropriate for situations that require urgent, real-time or phone-based interactions or complex project analysis and dump analysis issues. Issues of this nature are best handled working with a dedicated Microsoft Support Engineer by contacting Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscriptions/support/default.aspx. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights. Actually, I found the database provider code at
This doesn't resolve the second issue, however. Here's the code to reproduce the problem: Try Dim conn As New NpgsqlConnection(connStr) conn.Open() ... Catch ex As Exception Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "General Policy") If (rethrow) Then Throw End If End Try If the connection string is invalid or the database server is unavailable, the following occurs in "ExceptionPolicy.HandleException". As I've said, a tiny modification to the Enterprise Library alleviates the problem, but I'm still not sure whether that's the right approach. An unhandled exception of type 'System.Reflection.TargetParameterCountException' occurred in mscorlib.dll Additional information: Parameter count mismatch. Unhandled Exception: System.Reflection.TargetParameterCountException: Parameter count mismatch. at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess) at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean verifyAccess) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) at System.Reflection.MethodInfo.Invoke(Object obj, Object[] parameters) at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[] index) at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionFormatter ..WriteReflectionInfo(Exception e) in C:\Program Files\Microsoft Enterprise Library June 2005\src\ExceptionHandling\ExceptionFormatter.cs:line 174 at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionFormatter ..WriteException(Exception e, Exception outerException) in C:\Program Files\Microsoft Enterprise Library June 2005\src\ExceptionHandling\ExceptionFormatter.cs:line 132 at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionForma tter.WriteException(Exception e, Exception outerException) in C:\Program Files\Microsoft Enterprise Library June 2005\src\ExceptionHandling\TextExceptionFormatter.cs:line 107 at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionFormatter ..Format() in C:\Program Files\Microsoft Enterprise Library June 2005\src\ExceptionHandling\ExceptionFormatter.cs:line 85 at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionUtility.F ormatHandlingException(StringWriter writer, String header, Exception ex) in C:\Program Files\Microsoft Enterprise Library June 2005\src\ExceptionHandling\ExceptionUtility.cs:line 83 at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionUtility.L ogHandlingException(String policyName, Exception offendingException, Exception chainException, Exception originalException) in C:\Program Files\Microsoft Enterprise Library June 2005\src\ExceptionHandling\ExceptionUtility.cs:line 61 at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyEnt ry.ExecuteHandlerChain(Exception ex, Guid handlingInstanceID) in C:\Program Files\Microsoft Enterprise Library June 2005\src\ExceptionHandling\ExceptionPolicyEntry.cs:line 109 at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyEnt ry.Handle(Exception ex) in C:\Program Files\Microsoft Enterprise Library June 2005\src\ExceptionHandling\ExceptionPolicyEntry.cs:line 54 at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.Ha ndleException(Exception ex) in C:\Program Files\Microsoft Enterprise Library June 2005\src\ExceptionHandling\ExceptionPolicy.cs:line 146 at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.Ha ndleException(Exception ex, String policyName, ConfigurationContext configurationContext) in C:\Program Files\Microsoft Enterprise Library June 2005\src\ExceptionHandling\ExceptionPolicy.cs:line 107 at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.Ha ndleException(Exception ex, String policyName) in C:\Program Files\Microsoft Enterprise Library June 2005\src\ExceptionHandling\ExceptionPolicy.cs:line 67 at TPApp.ScheduleListener.Listen() in F:\TPApp\TPAppListeners\ScheduleListener\ScheduleListener.vb:line 38 On Thu, 20 Jul 2006 09:14:47 GMT, stch***@online.microsoft.com (Steven Cheng[MSFT]) wrote: Show quote >Hello Brad, > >Thank you for posting in the MSDN newsgroup. > >From your description, you're using the enterprise library to develop your >net application and when dealing with the PostgreSQL database, you're >wondering how to integrated the npgsql provider with enterprise library's >DAAB. Also, you're getting some other exceptions when the connection to >postgresql fails, correct? > >Based on my research, the npgsql managed provider for postgreSQL database >has only provided .net framework 1.1 based version. Therefore, I think your >application is also developing under .net framework 1.1 and the enterprise >library is of version 1.0(2.0 is specfic to .net framework 2.0), correct? > >In the enterprise library 1.0, the built-in database provdiers include SQL, >Oracle, DB2 database providers. As for postgreSQL, if you want to integraed >it into the enterprise library daab framework, you need to create a custom >database provider. This require the following work: >=========== >Create a new command wrapper that derives from DBCommandWrapper. >Create a new database class that derives from Database. >Additionally, if you want your client code to remain database-agnostic, you >may need to write additional code to perform such tasks as type conversion. >=========== > >You can find the "Adding a New Database Provider" topic in the >documentation of enterprise library 1.0(the latest version is 2005 June). > >As for the second problem you mentioned, what's the detailed behavior you >met when the Npgsql connection fails? Is the actual exception instance >thrown out to front UI? Based on my understanding, the exception handling >block let us define some exception management policy which can control how >to process when encountering some certain types of exception. What's the >underlying exception type it thrown when Npgsql connection fails(I think it >should be a Npgsql specific exception type) and have you explicitly >configured any policy for it(such as None, Notify and rethrow, or replacing >with new type). > >Hope this helps. > >Sincerely, > >Steven Cheng > >Microsoft MSDN Online Support Lead > > > >================================================== > >Get notification to my posts through email? Please refer to > >http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif >ications. > > > >Note: The MSDN Managed Newsgroup support offering is for non-urgent issues >where an initial > >response from the community or a Microsoft Support Engineer within 1 >business day is > >acceptable. Please note that each follow up response may take approximately >2 business days > >as the support professional working with you may need further investigation >to reach the > >most efficient resolution. The offering is not appropriate for situations >that require > >urgent, real-time or phone-based interactions or complex project analysis >and dump analysis > >issues. Issues of this nature are best handled working with a dedicated >Microsoft Support > >Engineer by contacting Microsoft Customer Support Services (CSS) at > >http://msdn.microsoft.com/subscriptions/support/default.aspx. > >================================================== > > > >This posting is provided "AS IS" with no warranties, and confers no rights. > > > > Thanks for your followup,
I noticed that you've defined the "Generic Policy", that's the detailed setting of this poilcy since it is when the runtime try applying this policy to handle the exception that cause the error occured. Sincerely, Steven Cheng Microsoft MSDN Online Support Lead I'm sorry, but I simply don't understand what this response means. Are
you saying I should be using a policy with a different name? I went through all of the setup steps for the policy I used. Are you saying there's a problem with my configuration? Brad. On Fri, 28 Jul 2006 09:34:35 GMT, stch***@online.microsoft.com (Steven Cheng[MSFT]) wrote: Show quote >Thanks for your followup, > >I noticed that you've defined the "Generic Policy", that's the detailed >setting of this poilcy since it is when the runtime try applying this >policy to handle the exception that cause the error occured. > >Sincerely, > >Steven Cheng > >Microsoft MSDN Online Support Lead > Hi Brad,
Sorry for the confusing. Yes, I mean to check whether it is the configuration error in the Exception Handing policy that cause the problem. Because the exception callstack indicate that the reflection (method invoke code) receive incorrect paratmer counts. Have you tried using the same setting for a different exception type (like the SqlException ...) to see whether the same error occurs. If not occurs, the problem should also specific to the Npgsql provider. Sincerely, Steven Cheng Microsoft MSDN Online Support Lead This posting is provided "AS IS" with no warranties, and confers no rights. |
|||||||||||||||||||||||