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.

Why aren't reference assemblies resolved from the GAC when running on full .NET Framework?

See original GitHub issue

I have a self-hosted (in a Windows Service) ASP.NET Core website running on full .NET Framework 4.6.1. When it is published and deployed to a machine that doesn’t have the reference assemblies (i.e. C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1 doesn’t exist) the website responds with:

InvalidOperationException: Can not find reference assembly ‘.NETFramework/v4.6.1/Microsoft.CSharp.dll’ file for package Microsoft.CSharp

My understanding is that these reference assemblies are only for design-time/compile-time support and are installed by tooling (SDKs/Visual Studio) and not by the .NET Framework itself. The publish target has .NET Framework 4.6.1 but doesn’t have the reference assemblies. If I copy the reference assemblies from my development machine to the publish target, everything works.

Is this a bug? Shouldn’t it be trying to resolve the assembly from the GAC?

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
aL3891commented, Sep 29, 2017

It can go in any top level property group, for example:

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <BuildForIIS>true</BuildForIIS>
  </PropertyGroup>
...

(it doesn’t have to have its own group though)

1reaction
EtharAlalicommented, Sep 29, 2017

Allan, thanks for this tip. Given the structure of the new VS2017 .NET CSProj files, where in the project file tree should the <BuildForIIS>true</BuildForIIS> go?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why aren't reference assemblies resolved from the GAC ...
My understanding is that these reference assemblies are only for design-time/compile-time support and are installed by tooling (SDKs/Visual ...
Read more >
.net - How should I fix/resolve exception The reference ...
Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your ......
Read more >
Resolving Assemblies at Design Time - MSBuild
Learn how MSBuild resolves references to assemblies at design time by using reference assemblies in the targeting pack.
Read more >
[VS Code] Error: The reference assemblies for framework ". ...
Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your ......
Read more >
NET Framework version hell on build server - Ivan Krivyakov
3. If it cannot find reference assemblies for that specific version, it will issue a warning and use assemblies from the GAC, which...
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