google-code-export / dblinq2007

Automatically exported from code.google.com/p/dblinq2007
Other
0 stars 0 forks source link

NpgsqlConnectionStringBuilder.Password setter fails #318

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a NpgsqlConnectionStringBuilder
2. Set its Password to some valid bytes, i.e.,
    csb.Password = UTF8Encoding.Default.GetBytes("password");
    (or ASCII as well)

What is the expected output? What do you see instead?
This should work.  Instead I get this stack trace:
Unhandled Exception: System.ArgumentException: Cannot convert object of type 
'System.Byte[]' to object of type 'System.String'. ---> 
System.InvalidCastException: Unable to cast object of type 'System.Byte[]' to 
type 'System.IConvertible'.
   at System.Data.Common.DbConnectionStringBuilderUtil.ConvertToString(Object value)
   --- End of inner exception stack trace ---
   at System.Data.Common.DbConnectionStringBuilderUtil.ConvertToString(Object value)
   at System.Data.Common.DbConnectionStringBuilder.set_Item(String keyword, Object value)
   at Npgsql.NpgsqlConnectionStringBuilder.SetValue(String keyword, Object value) in C:\projects\Npgsql2\src\Npgsql\Npgs
qlConnectionStringBuilder.cs:line 843
   at Npgsql.NpgsqlConnectionStringBuilder.set_Password(Byte[] value) in C:\projects\Npgsql2\src\Npgsql\NpgsqlConnection
StringBuilder.cs:line 414

What version of the product are you using? On what operating system?
Visual Studio 2010 on Windows 7 (Microsoft (R) Visual C# 2010 Compiler version 
4.0.30319.1)

Please provide any additional information below.
First, thanks very much for writing this software; it's great!  The workaround 
is simply to use: csb.Add("Password", "swordfish");
instead of: csb.Password = UTF8.Default.GetBytes("swordfish");

Original issue reported on code.google.com by LiamBo...@gmail.com on 23 Jun 2011 at 1:03