I have a webproject I am trying to host, but when the server tries to compile it, I get the following error:
Unhandled Exception: System.IO.FileLoadException: Could not load file
or assembly 'Microsoft.CodeAnalysis, Version=1.1.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35' or one of its
dependencies. The located assembly's manifest definition does not
match the assembly reference. (Exception from HRESULT: 0x80131040)
---> System.IO.FileLoadException: Could not load file or assembly 'Microsoft.CodeAnalysis, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35' or one of its
dependencies. The located assembly's manifest definition does not
match the assembly reference. (Exception from HRESULT: 0x80131040)
--- End of inner exception stack trace --- at Microsoft.CodeAnalysis.CSharp.CommandLine.Program.Main(String[] args)
So the server has an older version of CodeAnalysis than my project. So lets try a binding redirect!
<dependentAssembly>
<assemblyIdentity name="Microsoft.CodeAnalysis" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.9.9.9" newVersion="1.0.0.0" />
</dependentAssembly>
Sadly, I still get the same error. What am I doing wrong?
I figured this out myself. To anyone reading this, the problem was that the Nuget package Microsoft.CodeDom.Providers.DotNetCompilerPlatform (which also contains the CodeAnalysis package) was the wrong version. I created a new webproject, updated the offending Nuget package right away, and the problem was solved.
Other possible fix (at least for Visual Studio 2015):
Get the latest Visual Studio update.
You can check for updates by going to Tools/Extensions and Updates/Updates
Same as this Q/A: Visual Studio 2015: Quick Actions no longer working, error: Could not load file or assembly Microsoft.CodeAnalysis
I resolved this issue but ensuring that the version numbers of the assemblies in my web.config were correct.
Edit:
I hit this problem as well and some may wonder how the Web.Config can become incorrect. In my case I am using Web.Config Transforms so the Web.Config file gets overwritten:
Changing the version number in Web.Configs compiler (in the Web.Template.Config) to the number matches the NuGet version does solve the issue:
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.5.0
I have had this problem today while doing an Umbraco v7.13.0 upgrade, simply updating the following package has fixed my problem, this is apparently a common problem with things like Umbraco upgrades.
Update-Package -Reinstall Microsoft.CodeAnalysis.CSharp
If none of mentioned options work, please go for this answer. Basically, you are registering that Microsoft.CodeAnalysis.dll to GAC
Could not load file or assembly 'Microsoft.CodeAnalysis, version= 1.3.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependenc
Right click on your project >> Manage Nuget packages manager for solution >> Tap on Updates >> Update your 'Microsoft.CodeDom.Providers.DotNetCompilerPlatform' >> and then run your project again.
Related
I have a test project that references a dll project; this dll project references itself Azure Nugets, especially Azure.Storage.Blobs (v12.9.1)
One of my tests fails when reaching this instruction :
var blobServiceClient = new BlobServiceClient(connectionString);
Exception is :
System.IO.FileLoadException
HResult=0x80131040
Message=Could not load file or assembly 'System.Threading.Tasks.Extensions, Version=4.5.4.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Source=Azure.Storage.Blobs
StackTrace:
at Azure.Storage.Blobs.BlobServiceClient..ctor(String connectionString, BlobClientOptions options)
at Azure.Storage.Blobs.BlobServiceClient..ctor(String connectionString)
(…)
Inner Exception 1:
FileLoadException: Could not load file or assembly 'System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
I would like to understand and solve this exception.
Notes :
UnitTest Project is using .Net Framework 4.7.2
Referenced project is using .Net standard 2.0, and references itself other projects.
System.Threading.Tasks.Extensions is neither referenced explicitly by my test project, nor by referenced dll.
What I already investigated :
Add bindingredirect in Test Project App.Config :
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.5.4.0" newVersion="4.5.4.0" />
</dependentAssembly>
Note : For the next steps of my investigation, I kept this binding redirect
Check that System.Threading.Tasks.Extensions.dll is present in test project bin/debug folder => It is the case, this dll is present. Note : I don't know how to detrmine its nuget version (details in windows explorer only gives dll version)
Adding a reference to nuget System.Threading.Tasks.Extensions v4.5.4.0 (latest version) to unit test project
Adding a reference to nuget System.Threading.Tasks.Extensions v4.5.4.0 (latest version) to referenced project
Thanks for help.
Since this solves your issue, I made a summary and hope this could also benefit other forum members who meet the similar/same issue.
For element, consider using assembly version, instead of NuGet package version. See here for details.
For System.Threading.Task.Extensions NuGet package, currently, 4.5.4 is the newest NuGet package version and 4.2.0.1 is the newest assembly version, so try to use 4.2.0.1.
I have a C# / .NET Windows service that is archiving Exchange mailboxes, and I recently "packaged" the Veeam O365 Backup DLLs to be able to backup Exchange Online mailboxes automatically.
I 'll show you some piece of log showing that the program runs without issue for a while, then starts to fail out of nowhere with the error:
"Could not load file or assembly 'System.IO.Compression, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference."
... until the service is restarted:
(see Edit1, my picture got overwritten)
The stacktrace:
System.Management.Automation.CmdletInvocationException: Could not load file or assembly 'System.IO.Compression, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) ---> System.IO.FileLoadException: Could not load file or assembly 'System.IO.Compression, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
at Veeam.Core.FileLoggerTransport.AutoArchive()
at Veeam.Core.FileLoggerTransport.ArchiveAndDelete()
at Veeam.Core.FileLoggerTransport.ControlLogSize()
at Veeam.Core.FileLoggerTransport.WriteLine(UInt32 level, String message)
at Veeam.Core.LoggerTransport.LogDefault(UInt32 level, String message, Object[] args)
at Veeam.PowerShell.Core.BasePSCmdlet.BeginProcessing()
at System.Management.Automation.Cmdlet.DoBeginProcessing()
at System.Management.Automation.CommandProcessorBase.DoBegin()
--- End of inner exception stack trace ---
at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke)
at System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, Boolean isSync)
at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
at System.Management.Automation.PowerShell.Invoke(IEnumerable input, PSInvocationSettings settings)
at VeeamArchiverConnector.VeeamArchiverConnector.ConnectToVeeamServer(String serverName, Int32 port)
at REMOVED.DeprovisionObject.DeprovisionOnline(String deprovisioningOu) in C:\Users\REMOVED\Source\Repos\ExchangeProvisioning\Deprovisioning\DeprovisionObject.cs:line 442
at REMOVED.DeprovisionObject.Start() in C:\Users\REMOVED\Source\Repos\ExchangeProvisioning\Deprovisioning\DeprovisionObject.cs:line 125
The project does reference System.IO.Compression, although:
The Nuget Package version is "4.3.0"
The version on the reference is "4.1.2.0"
The file version once built is "4.6.24704"
In my .csproj file I have this:
<Reference Include="System.IO.Compression, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.Compression.4.3.0\lib\net46\System.IO.Compression.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
I don't have access to the code / project of "Veeam.Core.*" as they are Veeam DLLs coming with the Veeam O365 backup installer.
But globally what I don't understand, is the fact that it work for a while (usually around an hour or two), and then the error start unless I restart the service?
Any advise is welcomed!
Thanks
Edit 1 :
I added more logs and custom exception throw inside my "Veeam Connector" project, but it's the same thing: the final error is still about System.IO.Compression missing, and the inputs never changed:
detailedlogswithsteps
stillsameerrorevenwithcustomexception
#howcheng Thank you! That did the trick, service running for multiple hours with no issues.
So the issues was this binding:
<assemblyIdentity name="System.IO.Compression" publicKeyToken="b77a5c561934e089" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
That was redirecting to 4.2.0.0. I Suppose it was good on my only .NETFramework project, but as you mentioned, .NETStandard System.IO.Compression forces a version 4.1.2.0, and didn't update the binding when installed > so it was now trying to find 4.2.0.0, which was no more and it was only 4.1.2.0.
Updating the binding to "newVersion=4.1.2.0" did it!
I had the same problem. A netstandard2.0 library is using System.IO.Compression and is consumed from a .NET Fx 4.7.2 test project. The Could not load file or assembly 'System.IO.Compression, Version=4.2.2.0, Culture=neutral' exception happened when attempting to load System.IO.Compression from the netstandard2.0 code.
The fix was just to
reference System.IO.Compression from the .NET Fx 4.7.2 test project
call this method from the test, this way System.IO.Compression is resolved from a .NET Fx environement.
private static void AvoidCannotLoadSystemIOCompressionException() {
var justToAvoidStrangeException = ZipArchiveMode.Create;
}
Odd but it works
I am using the BreezeApi NuGet package in my project. It is in Visual Studio 2013.
I get this error.
Error 41 Assembly 'Breeze.WebApi2, Version=1.4.0.0, Culture=neutral, PublicKeyToken=f6085f1a45e2ac59' uses 'System.Web.Http, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' which has a higher version than referenced assembly 'System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
I don't know why my project keeps referencing the 4.0 version. Things I tried:
I removed the reference of system.web.http 4.0 from my project and browsed to the 5.0 DLL file location. As soon as I add it and come back to Solution Explorer, right click on the system.web.http dll, it is showing 4.0.0.0.
I added assembly binding in web.config like below
<dependentAssembly>
<assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.1.0.0" newVersion="5.1.0.0" />
</dependentAssembly>
How do I resolve this?
This is what I did to solve an issue very similar to yours:
Error 2 Assembly 'Breeze.WebApi2, Version=1.4.0.0, Culture=neutral,
PublicKeyToken=f6085f1a45e2ac59' uses 'System.Web.Http,
Version=5.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
which has a higher version than referenced assembly 'System.Web.Http,
Version=5.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35' c:\Repos\SPACodeCamper\packages\Breeze.Server.WebApi2.1.4.12\lib\Breeze.WebApi2.dll CC.Web
I got this error while doing the course Building Apps with Angular and Breeze - Part 1 by John Papa. It happened on step 3.15 after adding the Breeze Web API Controller to CC.Web.
To solve it we need to update the following NuGet Packages. I used NuGet Package Manager in Visual Studio 2013:
Microsoft.AspNet.WebApi.Client from 5.0.0 to 5.1.2
Microsoft.AspNet.WebApi.Core from 5.0.0 to 5.1.2
Microsoft.AspNet.WebApi.WebHost from 5.0.0 to 5.1.2
Microsoft.AspNet.WebApi.OData from 5.0.0 to 5.1.2 (this one I had to restart Visual Studio to complete the installation)
Updating the NuGet packages above will take care of bumping System.Web.Http's version to the correct one, in this case 5.1.0.0.
I think your answer is given here.
You have to update the NuGet packages. The easiest one is update-package in the NuGet packet manager console.
Be aware of other dependencies that might break.
I solved this by updating all my packages from NuGet.
I tinkered with my ASP.NET MVC4 packages via NuGet, and now System.Web.WebPages.Razor v3 won't load. Sometimes other packages won't load either.
My coworker runs the solution without any trouble, so the issue is definitely configuration on my development system (as opposed to anything that's been checked in).
I have already tried the recommendations at various SOf and other fora links, including:
Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.0.0.0,
Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.0.0.0
Could not load file or assembly 'System.Web.WebPages.Razor, Version=3.0.0.0
As well as suggestions linked from there. I also checked the Control Panel and found no installed programs that referenced MVC. (If it matters, I'm running MS Win 7 SP 1.)
I am open to any and all suggestions.
Here's my core dump info:
Server Error in '/' Application.
Could not load file or assembly 'System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or
one of its dependencies. The system cannot find the file specified.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.IO.FileNotFoundException: Could not load file or assembly 'System.Web.WebPages.Razor, Version=3.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its
dependencies. The system cannot find the file specified.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.
Assembly Load Trace: The following information can be helpful to determine why the assembly 'System.Web.WebPages.Razor,
Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
could not be loaded.
=== Pre-bind state information ===
LOG: User = CodesWithHammer
LOG: DisplayName = System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = file:///c:/users/CodesWithHammer/documents/visual studio 2012/Projects/MPP/MPP/
LOG: Initial PrivatePath = c:\users\CodesWithHammer\documents\visual studio
2012\Projects\MPP\MPP\bin
Calling assembly : Microsoft.Web.WebPages.OAuth, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: c:\users\CodesWithHammer\documents\visual studio
2012\Projects\MPP\MPP\web.config
LOG: Using host configuration file: C:\Users\CodesWithHammer\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: Attempting download of new URL file:///C:/Users/CodesWithHammer/AppData/Local/Temp/Temporary ASP.NET
Files/root/5bf3ca07/f960d9c5/System.Web.WebPages.Razor.DLL.
LOG: Attempting download of new URL file:///C:/Users/CodesWithHammer/AppData/Local/Temp/Temporary ASP.NET
Files/root/5bf3ca07/f960d9c5/System.Web.WebPages.Razor/System.Web.WebPages.Razor.DLL.
LOG: Attempting download of new URL file:///c:/users/CodesWithHammer/documents/visual studio
2012/Projects/MPP/MPP/bin/System.Web.WebPages.Razor.DLL.
LOG: Attempting download of new URL file:///c:/users/CodesWithHammer/documents/visual studio
2012/Projects/MPP/MPP/bin/System.Web.WebPages.Razor/System.Web.WebPages.Razor.DLL.
LOG: Attempting download of new URL file:///C:/Users/CodesWithHammer/AppData/Local/Temp/Temporary ASP.NET
Files/root/5bf3ca07/f960d9c5/System.Web.WebPages.Razor.EXE.
LOG: Attempting download of new URL file:///C:/Users/CodesWithHammer/AppData/Local/Temp/Temporary ASP.NET
Files/root/5bf3ca07/f960d9c5/System.Web.WebPages.Razor/System.Web.WebPages.Razor.EXE.
LOG: Attempting download of new URL file:///c:/users/CodesWithHammer/documents/visual studio
2012/Projects/MPP/MPP/bin/System.Web.WebPages.Razor.EXE.
LOG: Attempting download of new URL file:///c:/users/CodesWithHammer/documents/visual studio
2012/Projects/MPP/MPP/bin/System.Web.WebPages.Razor/System.Web.WebPages.Razor.EXE.
Stack Trace:
[FileNotFoundException: Could not load file or assembly 'System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The
system cannot find the file specified.]
Microsoft.Web.WebPages.OAuth.PreApplicationStartCode.Start() +0
[InvalidOperationException: The pre-application start initialization method Start on type
Microsoft.Web.WebPages.OAuth.PreApplicationStartCode threw an
exception with the following error message: Could not load file or
assembly 'System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The
system cannot find the file specified..]
System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection1
methods, Func1 setHostingEnvironmentCultures) +550
System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1
methods) +132
System.Web.Compilation.BuildManager.CallPreStartInitMethods(String
preStartInitListPath) +90
System.Web.Compilation.BuildManager.ExecutePreAppStart() +135
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager
appManager, IApplicationHost appHost, IConfigMapPathFactory
configMapPathFactory, HostingEnvironmentParameters hostingParameters,
PolicyLevel policyLevel, Exception appDomainCreationException) +516
[HttpException (0x80004005): The pre-application start initialization method Start on type
Microsoft.Web.WebPages.OAuth.PreApplicationStartCode threw an
exception with the following error message: Could not load file or
assembly 'System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The
system cannot find the file specified..]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9874840
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest
wr, HttpContext context) +254
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18055
(For those who read this far: I don't have enough reputation to make the tag pulling-out-my-hair. If there's an appropriate extant tag, please include that. KTHX.)
ETA: When I tried manually updating Microsoft.AspNet.Mvc to version 3, here's the error I got on Package Manager Console:
Install failed. Rolling back... Install-Package : Updating
'Microsoft.AspNet.Mvc 5.0.0' to 'Microsoft.AspNet.Mvc 3.0.20105.1'
failed. Unable to find a version of
'Microsoft.AspNet.Mvc.FixedDisplayModes' that is compatible wi th
'Microsoft.AspNet.Mvc 3.0.20105.1'. At line:1 char:16
+ Install-Package <<<< Microsoft.AspNet.Mvc -Version 3.0.20105.1
+ CategoryInfo : NotSpecified: (:) [Install-Package], InvalidOperationException
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand
ETA2: I got the packages directory from my coworker. They have MS.AspNet.Mvc v5, and they're running just fine. But they ALSO have MS.AspNet.Mvc.FixedDisplayModes v5. So I'm going to add both of those in. And yes, I have backed up my entire solution. :)
ETA3: So I re-upgraded to AspNet MVC v5, and skipped the deprecated Mvc.FixedDisplayNodes. Then I got a problem with conflicting versions of AspNet.WebPages, so I used this fix: Conflicting versions of ASP.NET Web Pages detected: specified version is "1.0.0.0", but the version in bin is "2.0.0.0" in ASP.MET MVC 3
And now my project runs!
Thanks all for the help!
You can find it in Nuget Package Microsoft ASP.NET Web Pages Version 3.2.0
If you have a reference to an earlier version than 3.0.0.0, Delete the reference, add the reference to the correct .dll in your packages folder and make sure "Copy Local" is set to "True" in the properties of the .dll.
Then in your web.config (as mentioned by #MichaelEvanchik)
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages.Razor" PublicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
"Update-Package –reinstall Microsoft.AspNet.WebPages"
Reinstall Microsoft.AspNet.WebPages nuget packages using this command in the package manager console.
same thing JUST happened to me with NUGET.
the following tag helped
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages.Razor" PublicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0"/>
</dependentAssembly>
Also if this is happening on the server, I had to make sure I was running the application pool on a more "privileged account" to the file system, but I don think that's your issue here
in the new actionmailer, "razorengine" is a dependency. The latest version of Razorengine installs the dependency to System.Web.Razor 3.0.0.
If you use an earlier version in your application (i suppose you are using actionmailer in another project and that you reference the mail functionality from another project) than you get this issue of course.
In an earlier application, i had a webapplication MVC that uses system.web.Razor version 2.0.0.
Of course, i got the issue to.
How to fix?
=> Simple!
Just uninstall the entire actionmailer in your actionmailer project.
Install a previous version of RazorEngin
Install-Package RazorEngine -Version 3.3.0 (because version 3.3.0 will reference system.web.razor 2.0.0)
Install actionmailer again (it will not install the latest version of RazorEngin because you allready did that yourselve)
Succes!
Is there a System.Web.WebPages.Razor.dll in the bin folder of your web app? What is its version? (Explorer right click, properties) I'm guessing it's not 3.0.0.0. Just get the nuget packages for v3.0.0.0, perhaps by copying the packages folder from your colleague. Or install it manually: http://www.nuget.org/packages/Microsoft.AspNet.Mvc/3.0.20105.1
EDIT: if you copy stuff from your colleague, also copy the relevant version numbers into packages.config. This is what tells nuget which versions to put into the packages folder.
I did not want to install visual studio and development environment, so I have installed AspNetMVC4Setup.exe in Windows server 2016 machine and it solved the problem. The installer was downloaded from Microsoft website.
In my case the issue didn't resolve by following any of the above methods. I had all the paths in my package config correct and the dll's were in place as referred, I was still getting run time error for System.Web.WebPages.Razor. I changed the localhost port number and this worked
I am not sure of why I had the issue and why changing the port number resolved it. Just posting this as I feel this might be useful for someone out there.
In my case, the issue was not about binding redirects or missing/mismatched Microsoft.AspNet.Razor package/dlls, so the above solutions didn't work.
The issue, in my non-web project, was that RazorEngine+Microsoft.AspNet.Razor were installed in a different project (Project A) than the calling assembly/start-up project (Project B). Because there's no explicit reference to Razor, the System.Web.Razor did NOT get copied to /bin in a Release build.
The solution was to Install RazorEngine+Microsoft.AspNet.Razor in the application entry point (Project B, ConsoleApplication in my case), then the System.Web.Razor gets copied to /bin and everyone's happy.
I got the same error, what worked for me is:
Fix references error.
Close Visual Studio.
Delete Packages.
Delete .vs folder.
Run Project Again.
Rebuild Project.
I got this problem because I uninstalled VS 2012, I don't want to reinstall it back, so I downloaded the AspNetMVC4Setup.exe from Microsoft.com and fixed my problem.
https://www.microsoft.com/en-us/download/details.aspx?id=30683
I had this issue when I upgraded to v3.0.0.preview4, so a downgrade to a stable version fixed this.
I got this error because such DLL (and many others) were missing in bin folder when I pubished the web application. It seemed like a bug in Visual Studio publish function. Cleaning, recompiling and publishing it again, made such DLLs to be published correctly.
After signing the third parties assemblies and adding them to GAC I am getting the below error: also the Assembly Binder Log Entry shows this error
It says mismatching assemblies not sure how mistnaching as I deleted all obj and bin fold and batch built the application + reimported the dlls.
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 = AKBARCA\user
LOG: DisplayName = ClubStarterKit.Core, Version=3.0.1.0, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase =
file:///C:/Users/user/Desktop/NhibernateMediumTrust/NhibernateMediumUpgrade/direct/clubstar
terkit v3 preview/ClubStarterKit.Web/
LOG: DEVPATH = C:\ProgramData\Red Gate\.NET Reflector\DevPath
LOG: Initial PrivatePath =
C:\Users\user\Desktop\NhibernateMediumTrust\NhibernateMediumUpgrade\direct\clubstarterkit v3 preview\ClubStarterKit.Web\bin
Calling assembly : ClubStarterKit.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
From my experience, this happens, usually once you've published your app and when you have different versions of nuget packages in play. If this happens to be your situation as well, the best way I've found to fix it is to right-click the solution (not the individual projects) and choose "Manage Nuget Packages". Then, locate the offending assembly in the installed packages. You'll probably see it listed multiple times. Click "Manage" on each of the older versions of the package and uncheck all your projects. Once only the latest version of the package remains in the list. Click "Manage" on this one and recheck any projects that need the package. This will essentially upgrade them all to use the same version of the package and should resolve your mismatch error.
I faced similar problem. In my case, I was having multiple projects in my solution.
One of the project was referring EntityFramework 4.0 and that project was being referred in another project that was referring to EntityFramework 5.0. I brought them in sync and the problem got away.
Hum...
I faced something similar with the same error message.
In my case I've updated manually the version of the assemblies.
In the referenced assembly I had another version...
So, I updated it in the web.config.
This solved my problem.
Your === Pre-bind state information === seems incomplete.
Generally it shows the execution and the last line shows the error, so, we can help only sharing our experiences.
Example:
I hope someone else facing this problem find this helpful.
In my case, the error happens when the version specified in web.config's <bindingRedirect> of the dependent assembly (e.g. Newtonsoft.Json) doesn't match the version that is actually in the bin folder. Once the version number in the web.config is updated, the problem is fixed.
When I experienced this problem in the past, I deleted all my project's dll's from the gac, rebuilt the solution, then did iisreset and it was solved.
One way to solve this could be, going under "Manage NuGet Packages for Solution" by doing right click in the solution explorer.
Once there, go to "Consolidate" and find the package that is causing the problems. Make sure that all the projects within the solution are using the same version.
I had a different cause: in my case, I had used various nuget package versions previously, and I had an app.config which for some reason had been automatically generated with this kind of content:
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.DependencyInjection" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.1.1.0" newVersion="1.1.1.0" />
</dependentAssembly>
So I only had Version 1.1.0.0 installed, but because of this redirect instruction, it looked for 1.1.1.0 even though Visual Studio had the nuget for 1.1.0.0 installed. Changing the newVersion to 1.1.0.0 fixed everything:
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.DependencyInjection" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.1.1.0" newVersion="1.1.0.0" />
</dependentAssembly>
I got this error using FASTjson:
_jsonConfig = fastJSON.JSON.ToObject<jsonConfig>(jsonConfigFileContents);
It failed on this line:
Type t = Type.GetType(typename);
Which causes an exception in System.RuntimeTypeHandle.GetTypeByName
The problem was a difference in the JSON file compared to the JSON Object Model.
The solution is to re-save the JSON Object Model to file, eg:
string jsonSettings = fastJSON.JSON.ToJSON(JSONObjectModel);
File.WriteAllText(JSONFilePath, jsonSettings);