Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NpgsqlConnectionStringBuilder.Password setter fails #318

Open
GoogleCodeExporter opened this issue Apr 24, 2015 · 0 comments
Open

NpgsqlConnectionStringBuilder.Password setter fails #318

GoogleCodeExporter opened this issue Apr 24, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

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 [email protected] on 23 Jun 2011 at 1:03

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant