'c# - hiding a connection in a .dll
I'm new to c#, but I need to change an existing program, by merely changing the connection string. The idea is to redirect the connection to a test database environment. I've found that the code uses a dll to create a connection to the server. I used Jetbrains Dotpeek to look inside the dll, but I could only see methods and functions, but nowhere could I see the connection detail to change it.
What ways are there of encrypting a connection string? Are there special files used generally for this, that I can look for?
To give more elaborate information:
In the normal code in the cs file, there is for example this:
var result = new LibSqlQuery(Db.ABC.ConnectionString, sql);
return result;
and Db is a method in a dll defined as following:
public static class Db
{
private static Dictionary<string, LibDbConnection> _connections = new Dictionary<string, LibDbConnection>();
private static LibDbConnection GetConnection(string connectionName)
{
lock (Db._connections)
{
if (!Db._connections.ContainsKey(connectionName))
Db._connections.Add(connectionName, new LibDbConnection(connectionName));
}
return Db._connections[connectionName];
}
public static LibDbConnection ABC => Db.GetConnection("conABC");
public static LibDbConnection CDE => Db.GetConnection("conCDE");
}
where ABC and CDE are database environments.
Solution 1:[1]
I found another config file, which had the connections. This can be closed now. Thank you.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
