I have an old ASP.NET web application on a server, which was developed in Visual Studio 2008 in the year 2008. The server now has .NET 4.0 installed also. When I try to access the web app I get:
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS1703: An assembly with the same identity 'System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' has already been imported. Try removing one of the duplicate references.
Source Error:
[No relevant source lines]
Is there anything I can do to get it to work without access to the original Visual Studio solution? I believe it has to do with the fact that .NET 4.0 is also installed on the server.
1) Have you checked the application pool your application is running under? Is it still .net 2.0 integrated/classic, or has it automagically changed to 4.0? If so, try changin back to 2.0.
2) Do you by any chance have a System.Web.Extensions.dll in the bin folder of the application? If so, try renaming it (similar situation as here)
3) If 1 is not an option and 2 is not the case, do you have any explicit references to the System.Web.Extensions in the app's config file? Are they requesting a different version of the file?
Related
I'm creating an ASP.NET API Core application, to handle API services, which communicate to an Oracle Database.
At runtime, when the process tries to connect to the DB with a new Oracle Connection throught a DbContext ( Entity Framework) an unhandled error appears and forces the app to stop.
myDbContext.Database.Connection.Open();
This line causes the following error
System.TypeLoadException : 'Could not load type
'System.Security.Principal.WindowsImpersonationContext' from assembly
'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=xxx'.'
I had an old but similar project which used the same code and worked properly.
The library used is the same for Oracle Connector : Oracle.ManagedDataAccess.EntityFramework
What I tried :
Unistall - Reinstall Oracle.ManagedDataAccess.EntityFramework,
same for other Oracle connector ( Oracle.ManagedDataAccess, Oracle.ManagedDataAccess.Core )
Install System.Security.Principal
Changing the target framework from 3.1 to 5
I went first to this page 'System.Security.Principal.WindowsImpersonationContext' from assembly 'mscorlib' error when trying to parse template with Razor Engine but did not find anything that could help me resolve this.
For dot net 6, I was getting the same exception. Only kept the package: Oracle.ManagedDataAccess.Core and removed all others related to oracle and it works.
Get rid of 'Oracle.ManagedDataAccess'. I had both 'Oracle.ManagedDataAccess' and 'Oracle.ManagedDataAccess.Core' installed. This issue is most likely caused because 'Oracle.ManagedDataAccess' is for .NET Framework and not .NET Core/.NET 6.
I had the same problem. The .NET Core version has the same name as the .NET Framework version Oracle.ManagedDataAccess.dll but with a lower version number. As a result, Visual Studio takes the higher version from the GAC rather than the NuGet package. -> Delete the GAC version.
I am trying to run an website that I have hosted an IIS server using localhost, however, the MVC 5 project I have created uses .NET 4.5.1 and in IIS App pool I have selected v4.0 - Is this right?
The reason why I have asked is when I browse to the site, I get this error
Server Error in '/' Application.
Could not load file or assembly 'Microsoft.Web.Infrastructure,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or
one of its dependencies. The system cannot find the file specified.
I realise this is a reference problem but I have a feeling its to do with IIS and the app pool.
Any ideas?
Please note I am deploying the site onto a different server
Thanks
OK, found the answer,
Even though the Microsoft.Web.Infrastucture is referenced in the project (if not, get it using NuGet) you need to change CopyLocal to equal true when you click on the reference. Do this when deploying onto a server when Visual Studio isn't installed
I am using Visual Studio 2012 Update 3 and whenever I create a new ASP.NET empty website and build it for the first time compilation is successful but I get a server error when accessing the site of "Could not load file or assembly 'System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The module was expected to contain an assembly manifest."
If I then go back and build the website again I get a single error of "Object reference not set to an instance of an object" but no line number.
This error occurs whichever framework I am targeting and whether I am using C# or VB.
Can anyone point me in the right direction please?
Thanks,
Richard.
Possibly AjaxControl Toolkit is the issue.
Depending on your Framework version( 4.5, 4.0, 3.5 ),, install the correct version of AjaxControl Toolkit from here: http://ajaxcontroltoolkit.codeplex.com/releases/view/94873.
Another solution I found is to place System.Web.Extensions.dll and System.Web.Extensions.Design.dll directly in the Bin folder of your web application.
I have a Silverlight site hosted in an asp page, it has been developed using vs2010 using .net 3.5 framework and silverlight 4. It all works on my dev box. However when I publish the site and get it deployed I get the error:
Could not load file or assembly 'Moe.Tactical.Ttas.Web' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
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.BadImageFormatException: Could not load file or assembly 'Moe.Tactical.Ttas.Web' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
I have checked that the ISS asp setting are using 2.0.50727, and that all my references are using that runtime also.
I am not sure what to do to work out what the missing dependencies are at this point (I don't have access to the deployment box, I will have to go and sit with a system admin).
This looks like a case of the GAC, and nothing to do with Silverlight/VS 2010/whatever.
Basically that assembly lives in the GAC of your dev box, but now on your production box, and the DLL is not included in your build.
I was actually exactly the opposite of 'TheGeekYouNeed's suggestion ... the system administrator had not followed my instructions, and had included a couple of extra assemblies in my bin folder, lol.
So interestingly it was complaining about having an extra file! (well actually an extra file that was probably a .net 4 one)
I'm having a problem when browsing a published site on local iis7 (on windows 7).
When browsing the asp.net site through VS2008 with F5 (dev iis) it works fine. When publishing it and browsing, I get a:
Server Error in '/MySite' Application.
The specified module could not be found. (Exception from HRESULT: 0x8007007E)
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: The specified module could not be found. (Exception from HRESULT: 0x8007007E)
Stack trace offers no clue on the problematic dll either. I copied the same published folder to a different machine (also with windows 7 32bit and iis 7) and it works.
Since this is a fresh install of iis on my machine, I verified the matching selected items in "Turn Windows Features on/off". After noticing the issue I also ran the "aspnet_regiis" util, but the problem remains.
The web site includes several external dlls (native and managed) and they all appear in the published bin folder (which is identical to the development bin folder)
Any insights?
Cheers,
Shay
As gleaned from this thread: http://social.msdn.microsoft.com/forums/en-US/netfx64bit/thread/f609f52e-00f6-4ada-9d6e-7129b85d3d4d/, as mentioned toward the bottom of the thread (second to last post as of right now), our problem was a "rogue" dll, Microsoft.SqlServer.Replication.dll. We simply removed the dll and no more error. Additionally, as no project in the solution referenced this dll, I simply removed it from the bin file and subsequent builds/publishes do not add the dll. I have no idea how the dll got in the bin file in the first place. A college prank, maybe.
Native dlls are supposed to be locatable in the PATH. Problem was they were under the User PATH and not the System PATH, so it worked fine through the VS but not through the IIS. I added the dll folder to the system PATH and everything worked...
A long shot in most cases but check you have good .NET Framework libraries. Was getting nothing from old Framework 2.0 website maintained with VS 2005 running on IIS 6 except plain text in browser window stating the error. Fiddler and Firebug reveled nothing. Started checking this, that and the other thing. Perhaps when wondering about using aspnet_iisreg that the C:\Windows\Microsoft.NET\Framework\v4.0.30319 folder was discovered to have only a handful of files. Doesn't make a lot of sense, the applications were 2.0 but there is some cross application communication and several libraries so maybe some are run as 4.0 or it might be that IIS will try to use some things from the highest version of .NET Framework available.
A co-worker more knowledgeable about servers repaired the 4.0 Framework with the stand alone installer from here.
Runs well now.
This error occurred for me when the .Net Framework on the target server was only 4.5.2 and a recently upgraded Nuget package required 4.7.2. To temporarily solve it, we downgraded the Nuget library to a previous version that did not require 4.7.2 until we can upgrade the server library.
This was in spite of our project properties having .NET Framework 4.5.2 selected as a target framework.