I inherited some old legacy code which I'm trying to build, but I'm missing some specific dlls. In particular, I need version 4.0.0.0 of System.ComponentModel.Composition, but the Nuget Package Manager options only go down to 4.5.0. Why is this, and how can I get the version I need?
Here is the line specified by the Web.config file I inherited.
<add assembly="System.Net.Http.WebRequest, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
__
Edit: I tried Jingmiao Xu-MSFT's solution but I'm getting an error saying I'm already referencing these packages. Then I noticed that I'd commented out these assembly lines in my Web.config, so where are these packages being referenced from?
According to your description, you can refer to the following steps to find the dlls you need:
Right-click on the References under your project in Solution Explorer.
Choose Assemblies and search System.ComponentModel.Composition, System.Net.Http.WebRequest
Check them and add them to the project.
When i build locally it works, but my VSTS hosted 2017 instance build fails with the following message:
[error]apps\Ascend.Identity\AccountController.cs(126,17): Error CS0012: The type 'HttpRequestMessage' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Locally, there is also a yellow triangle in the reference list.
but it still builds
and the reference is there in csproj
and the package is restored from nuget (packages.config)
<package id="System.Net.Http" version="4.3.3" targetFramework="net472" />
In your local, try the steps below:
Delete packages folder in your source directory.
Remove System.Net.Http reference.
Right click References, select Manage Nuget Packages, browser and install package System.Net.Http.
Build your project and check the result. Make sure there is no yellow triangle in the reference list.
Check in the changes and queue a build.
For this error, I have tried multiple solutions which is provided by Github. But, none of them worked. Please help to check whether this issue reopen on new environment like below.
Environment:
VS 2017 Version 15.4.1
Dotnet Version 2.0.2
Reproduce Steps:
Create an Asp.Net Core Web Application->.NET Core and Asp.net Core 2.0-> Web Application(Model-View-Controller)
Create an xUnit Test Project(.NET Core)
Follow this link Integration testing in ASP.NET Core
Add true to Test.csproj which is pointed at above link.
Run test method will return below error.
Microsoft.AspNetCore.Mvc.Razor.Compilation.CompilationFailedException : One or more compilation failures occurred:
ewiqttdv.z4g(4,62): error CS0012: The type 'Attribute' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
Update:
After following this suggestion , this error gone, but, it produce below new error.
Message: System.IO.FileNotFoundException : Could not load file or assembly 'Microsoft.VisualStudio.Web.CodeGeneration, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
What is the possible way to resolve "Microsoft.AspNetCore.Mvc.Razor.Compilation.CompilationFailedException"?
Any help would be appreciated.
A bit late, but I ran in to the same problem today and managed to fix the "Could not load file or assembly 'Microsoft.VisualStudio.Web.CodeGeneration ..." error by adding the following reference to my integration test project:
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.1" PrivateAssets="All" />
I have an "old" XAML Build Definition, made in Visual Studio; which builds a solution and following runs unit tests.
Now I've tried to make the same in the new TFS 2015 web surface.
I've created a build task, following Visual Studio Test.
But now the Test-Task exit with code 1 and gives me a lot of
"System.IO.FileNotFoundException: Could not load file or assembly" errors.
And also "Warning: MSTestAdapter failed to discover tests in class ..."
All the DLLs are where they have to be, the new definition has the same directory structure like the old one, but the test-task says there are missing assemblys.
Any ideas?
Update:
No, I still have the same error messages:
Warning: Unable to load types from the test source 'J:\xyz-Tests.dll'. Some or all of the tests in this source may not be discovered. If you are running unit tests for Windows Store apps and referencing custom WinMD type then please visit http://go.microsoft.com/fwlink/?LinkId=238340 for more info. Error details: System.IO.FileNotFoundException: Could not load file or assembly 'xyz_Commons, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
System.IO.FileNotFoundException: Could not load file or assembly 'xyz_Processing, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
System.IO.FileNotFoundException: Could not load file or assembly 'xyzCommons, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
This should exactly be the issue mentioned in below article, please try following the workaround to fix it:
Running Coded UI Tests built using Visual Studio 2013 with Team Foundation Server 2015
Test execution is failing in this scenario because test execution
engine is not able to resolve the old version binaries while executing
tests in a 14.0 environment (TFS 2015).
So, you need to update the projects to reference the new versions of the assemblies (VS 2015 in this scenario) using the assembly bindings in the test projects config file.
As a workaround to this issue, add an ‘app.config’ file to your
solution (See how to add app.config
https://msdn.microsoft.com/en-in/library/ms184658.aspx) and update the
contents of the file with the shared on OneDrive . The updated
configuration files contain assembly redirects from version 12.0 to
14.0, which will make sure that the test agent machine is able to resolve the framework assemblies. Check-in the updated configuration
file into the source control repository and run the BDT scenario once
again. The tests should run fine this time. If the test execution
again throws an error complaining version mismatch for some other
assembly, add the assembly to the app.config file and retry.
You can also reference this article :
http://www.dotnetcatch.com/2015/10/01/tfs-2010-to-2015-upgrade-codedui-feature-test-builds/
Could not load file or assembly 'Microsoft.VisualStudio.Web.PageInspector.Loader, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The module was expected to contain an assembly manifest.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable C:\Program Files (x86)\Common Files\Microsoft Shared\DevServer\11.0\WebDev.WebServer40.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: User = TTLWIN2K\miralp
LOG: DisplayName = Microsoft.VisualStudio.Web.PageInspector.Loader, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
(Fully-specified)
LOG: Appbase = file:///C:/SVN/temp/components/src/MasterpassProxy/src/Webservice/
LOG: Initial PrivatePath = C:\SVN\temp\components\src\MasterpassProxy\src\Webservice\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\SVN\temp\components\src\MasterpassProxy\src\Webservice\web.config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Microsoft.VisualStudio.Web.PageInspector.Loader, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
I just ran into the same problem, and the culprit was my uninstalling of Visual Studio Express 2012. It's possible that it might be any version of Visual Studio, as comments on this answer are indicating the issue still happens with Visual Studio 2019. My overall order of operations was:
Installed Visual Studio Express 2012 (long time ago)
Used Visual Studio Express 2012 happily for many months
Installed Visual Studio 2013 Premium
Used Visual Studio 2013 Premium happily for weeks
Uninstalled Visual Studio Express 2012
ERROR
I'm not 100% certain on the cause of it, or what combinations of Visual Studio versions would exhibit this behavior. But the solution for me was to edit the root web.config files in the framework directories:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\web.config
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\web.config
(For different framework versions you may have different folders.)
And remove the nodes:
<remove assembly="Microsoft.VisualStudio.Web.PageInspector.Loader, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<add assembly="Microsoft.VisualStudio.Web.PageInspector.Loader, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
Be careful not to remove any opening/closing parent nodes which are also on the same line(s) as these.
This resolved the issue for me.
No need to remove those lines
Just close and reopen the Visual studio with Admin privileges.
I got the same problem but not on my development machine but on hosting server.
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\web.config
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\web.config
I was able to fix it by adding below code to my web.config
<compilation targetFramework="4.5">
<assemblies>
<remove assembly="Microsoft.VisualStudio.Web.PageInspector.Loader,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</assemblies>
</compilation>
or by removing reference to this assembly from web.config files in framework directories.
I never installed VS there and i never had PageInspector installed there. Any idea why those configs reference them?
Update: fixed in Visual Studio 2019 Version 16.0.3 according to this page.
If this happens after upgrading to Visual Studio 2019 RC, the following workaround helped:
Find the download cache directory
Use Explorer or better to find the AspNetDiagnosticPack.msi within this directory.
Run (double-click) the AspNetDiagnosticPack.msi file (this will force the installation of this MSI).
Workaround found here
I had this issue after installing Visual Studio 2019 (whilst 2017 was still installed). It's caused by a missing component - AspNetDiagnosticPack.msi - that fails to install a required package into C:\ProgramData\Microsoft\VisualStudio\Packages\
The solution that worked for me was this:
Close Visual Studio
Download the package from:
https://download.visualstudio.microsoft.com/download/pr/e13d544f-5a3c-4bb3-9a7c-1e56b1f90e10/f8e5888ff01a7009ef8c2ef16aa02ab9/aspnetdiagnosticpack.msi
Run the installer and install.
This should fix it.
More information can be be found: https://developercommunity.visualstudio.com/content/problem/398640/could-not-load-file-or-assembly-microsoftvisualstu-7.html
For those who might end up here, try removing the following line in the Web.Config file of your Project while debugging
<identity impersonate="true" userName="blah" password="blah">
It took time until I finally came across the following thread:
Could not load file or assembly or one of its dependencies. Access is denied. The issue is random, but after it happens once, it continues
I've ran into this error while trying to run an ASP.NET project in VS2013 after having uninstalled a VS2015 preview. Repairing the VS2013 installation seems to have solved the problem.
I got this answer is perfect for me
No need to remove those lines
Just close and reopen the Visual studio with Admin privileges.
I removed the dll from gac and it started working. I am not sure where those dlls came from. If you have 2 or more versions of visual studio, reinstall the last version.
Try updating your Microsoft.ApplicationInsights nuget package. This also installs other dependencies. I ran into this problem when I had to change my Target Framework.
Tools > NuGet Package Manager > Manage NuGet Packages for
Solution...
search for "applicationinsights"
or run
Install-Package Microsoft.ApplicationInsights
Had a similar problem (another assembly) and for me it was a missing line in the web.config on the machine. A line that I think lets the web server load (any?) dll.
I had to add "*" to the compilation-assemblies list in the web.config:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\web.config
Like this
<compilation>
<assemblies>
...
<add assembly="*" />
</assemblies>
</compilation>
To find it I had to compare the file with one from a working server.
So it seems to me that It really is a load failure, but to determine why it fails, we need to be Sherlook H..
Normally I use a tool like ProcessMonitor to find out why I get a Load Failure, but this time, of course, it gave me no useful output.. IIS never tried to load the assembly!
If you don't see web.config in both of paths:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\web.config C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\web.config
file "Web" is in "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\" what I really want to show you, It's Web.config, you should open it with: notepad++... and remove:
//<remove assembly="Microsoft.VisualStudio.Web.PageInspector.Loader,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />"
I finish my problem with them.
Our project had (incorrectly) reference to the PageInspector.Loader.dll in the GAC for a long time:
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.Web.PageInspector.Loader">
<HintPath>..\..\..\..\..\..\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.VisualStudio.Web.PageInspector.Loader\v4.0_1.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Web.PageInspector.Loader.dll</HintPath>
</Reference>
</ItemGroup>
It worked for some time, but recently deployment to Azure caused the error "Can not find compilation library location for package Microsoft.VisualStudio.Web.PageInspector.Loader".
We found and deleted the reference from .csproj file and the problem was fixed.
I opened today a 10 year old project and encounter this issue in VS 2019 (16.9.1), in my case it was
<trust level="Medium"/>
removing above line from the web.config or setting <trust level="Full"/> solved this issue.
I know this is an old one but I ran into this error when debugging with Visual Studio 2010 (I also run 2013, 2017 and 2019 on the same machine...I have a few legacy apps :oP). In my case, I debug using local IIS as webserver (not express) and I ended up having to recycle the websites Application Pool which did the trick to clear the error (after restarting 2010).
Dave
it solved the problem on at my end by applying the approved solution in this thread.
modifying the following two files, and removing Microsoft.VisualStudio.Web.PageInspector.Loader resolved the issue.
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\web.config
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\web.config