question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question: GetConnectionString in Microsoft.Extensions.Configuration.ConfigurationExtensions

See original GitHub issue

Asp.NET Core v3.0

In VS2019 I press F12 while method GetConnectionString is in focus and a metadata file opens, where it shows the location of the source code:

// C:\Program Files\dotnet\packs\Microsoft.AspNetCore.App.Ref\3.0.0\ref\netcoreapp3.0\Microsoft.Extensions.Configuration.Abstractions.dll

Now when I open the above dll, my Decompiler shows

public static string GetConnectionString(this IConfiguration configuration, string name) { throw null; }

But this is not the implementation. So I searched for it in this repo and found this ref branch which depicts this code above and a src branch which shows the actual implementation:

public static string GetConnectionString(this IConfiguration configuration, string name) { return configuration?.GetSection("ConnectionStrings")?[name]; }

What is the `ref` branch? Or better, why do I not see the real implementation when using my decompiler

Ref branch: src/Configuration/Config.Abstractions/ref/Microsoft.Extensions.Configuration.Abstractions.netstandard2.0.cs

Src branch: src/Configuration/Config.Abstractions/src/ConfigurationExtensions.cs

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
MSDN-WhiteKnightcommented, Oct 2, 2019

It does not make decompiler obsolete, you just have to supply actual implementation assembly as input for it. It is contained in Microsoft.Extensions.Configuration.Abstractions in lib subdirectory. It should be cached somewhere on your local disk if you were recently building something targeting it; or you can load it from NuGet Gallery yourself if it’s not.

No idea why source.dot.net currently works so horribly and fails to find half of BCL types, though. Hope that’s just a temporary issue.

1reaction
gfoidlcommented, Oct 1, 2019

In short: it is better for tooling (Visual Studio).

Further infos:

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Cannot resolve symbol GetConnectionstring
I can't access it. using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; //no underlines and imported via Nuget ...
Read more >
ConfigurationExtensions.GetConnectionString ...
Retrieves the value with the specified key from the ConnectionStrings section of the configuration source. Calling this method is shorthand for ...
Read more >
How to fix "System.NullReferenceException" When ...
I'm using ASP.net Core App to connect to MSSQL database. I checked the connection when - Connect to Database and the database is...
Read more >
I have an error regulating upon visual studio it displays An ...
When using the ConfigurationExtensions.GetConnectionString method, it will retrieve the value with the specified key from the ConnectionStrings ...
Read more >
The ConnectionString property has not been initialized. ...
When use the GetConnectionString() method, it will look for a configuration value whose key is ConnectionStrings:<connection string name> . But ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found