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

Cloning FbConnection without connection string throws exception [DNET141] #151

Closed
firebird-automations opened this issue Dec 3, 2007 · 4 comments

Comments

@firebird-automations
Copy link

Submitted by: @cincuranet

If you try to run this code

FbConnection fbConnection = new FbConnection();
FbConnection fbConnection1 = (FbConnection)((ICloneable)fbConnection).Clone();

it will throw exception.

It's because if we create FbConnection without connection string in ctor, we're internally assigning empty string. But when cloning the connection, we put property to ctor and then this is validated and fails. I suppose:
* to test in Clone method whether connection string is empty (or null) and if so create FbConnection with null in ctor param [this is least painful solution]
OR
* not to assing internally empty string but leave it null (if no connection string has been provided) [this is maybe a bit more clear solution, but needs to review code on various place, whether something doesn't depends on empty connection string]

Commits: ebdc4c0

@firebird-automations
Copy link
Author

Modified by: @cincuranet

description: If you tryt o run this code

FbConnection fbConnection = new FbConnection();
FbConnection fbConnection1 = (FbConnection)((ICloneable)fbConnection).Clone();

it will throw exception.

It's because if we create FbConnection without connection string in ctor, we're internally assigning empty string. But when cloning the connection, we put property to ctor and then this is validated and fails. I suppose:
* to test in Clone method whether connection string is empty (or null) and if so create FbConnection with null in ctor param [this is least painful solution]
OR
* not to assing internally empty string but leave it null (if no connection string has been provided) [this is maybe a little bit clear solution, but needs to review code on various place, whether something doesn't depends on empty connection string]

=>

If you try to run this code

FbConnection fbConnection = new FbConnection();
FbConnection fbConnection1 = (FbConnection)((ICloneable)fbConnection).Clone();

it will throw exception.

It's because if we create FbConnection without connection string in ctor, we're internally assigning empty string. But when cloning the connection, we put property to ctor and then this is validated and fails. I suppose:
* to test in Clone method whether connection string is empty (or null) and if so create FbConnection with null in ctor param [this is least painful solution]
OR
* not to assing internally empty string but leave it null (if no connection string has been provided) [this is maybe a little bit clear solution, but needs to review code on various place, whether something doesn't depends on empty connection string]

@firebird-automations
Copy link
Author

Modified by: @cincuranet

description: If you try to run this code

FbConnection fbConnection = new FbConnection();
FbConnection fbConnection1 = (FbConnection)((ICloneable)fbConnection).Clone();

it will throw exception.

It's because if we create FbConnection without connection string in ctor, we're internally assigning empty string. But when cloning the connection, we put property to ctor and then this is validated and fails. I suppose:
* to test in Clone method whether connection string is empty (or null) and if so create FbConnection with null in ctor param [this is least painful solution]
OR
* not to assing internally empty string but leave it null (if no connection string has been provided) [this is maybe a little bit clear solution, but needs to review code on various place, whether something doesn't depends on empty connection string]

=>

If you try to run this code

FbConnection fbConnection = new FbConnection();
FbConnection fbConnection1 = (FbConnection)((ICloneable)fbConnection).Clone();

it will throw exception.

It's because if we create FbConnection without connection string in ctor, we're internally assigning empty string. But when cloning the connection, we put property to ctor and then this is validated and fails. I suppose:
* to test in Clone method whether connection string is empty (or null) and if so create FbConnection with null in ctor param [this is least painful solution]
OR
* not to assing internally empty string but leave it null (if no connection string has been provided) [this is maybe a bit more clear solution, but needs to review code on various place, whether something doesn't depends on empty connection string]

@firebird-automations
Copy link
Author

Modified by: @cincuranet

status: Open [ 1 ] => In Progress [ 3 ]

@firebird-automations
Copy link
Author

Modified by: @carlosga

status: In Progress [ 3 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

Fix Version: 2.5.0 [ 10170 ]

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

2 participants