TypeInitializationException when instaling CORS - c#

I have made a Web Api app and I want to access this api from a separate
website using Ajax.
To access the api I need to install CORS, but when doing so I get the
error (when Debuging):
An exception of type 'System.TypeInitializationException' occurred in MvcApplication1.dll but was not handled in user code
Additional information: The type initializer for 'System.Web.Http.GlobalConfiguration' threw an exception**
This error occurs within Global.asax.cs at:
WebApiConfig.Register(GlobalConfiguration.Configuration);
After rebuilding the solution and Debuging it again, I get navigatet to the webpage wich then show another error message:
Cannot create/shadow copy 'EntityFramework' when that file already exists.**
The Web Api worked perfect before I installed CORS, other than not
be able to access the api from a another website/location, witch is what I want...

The release candidate it should fix the error. Open the package mangaer console and copy/paste the below command.
Install-Package Microsoft.AspNet.WebApi -IncludePrerelease

Related

when I published asp net core 5 project on IIS it has an error

when i run my project in visual studio 2019 is good but when i publish my project on IIS occurs an error.
An unhandled exception occurred while processing the request.
NullReferenceException: Object reference not set to an instance of an object.
i'm using mediatr an 5 Layers clean;
I register MediatR on Startup but the error is not solve.
services.AddMediatR(typeof(YarnSystemCommandDTO).GetTypeInfo().Assembly);
services.AddScoped(typeof(IGenericRepository<>), typeof(GenericRepository<>));
To debug this situation, the callstack of the first chance exception will most like help. A simple way is to introduce a one-minute-delay to the entry point of your application, so you have time to attach to your w3wp process to catch the exception at startup. Make sure "Just My Code" is disabled.
the Problem was about Db connection and i add access of user: 'IIS APPPOOL\tqcApi' in database

C# MVC - Strange compilation error code -2146232576

I published a web app with C# MVC on IIS, but when I try to access the site, the server show this error; But I published the same web app in other Server and this run without issues. (I updated the NugetPackage)
Server Error in '/Outlet' Application.
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: The compiler failed with error code
-2146232576.
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.36392
I'm searching for this error code but don't find any solution, someone knows the possible solution for this error code?

Getting an error message "An error occurred while starting the application." after publishing an API app from Visual Studio 2017

I have a class library project based on .NET Framework 4.6.1. And another project is .NET service again based on .NET Framework 4.6.1. When I publish my service from visual studio 2017 to an API app in Azure, I get below error screen.
Few logs found:
IIS received the request; however, an internal error occurred during the processing of the request. The root cause of this error depends on which module handles the request and what was happening in the worker process when this error occurred. IIS was not able to access the web.config file for the Web site or application. This can occur if the NTFS permissions are set incorrectly. IIS was not able to process configuration for the Web site or application. The authenticated user does not have permission to use this DLL. The request is mapped to a managed handler but the .NET Extensibility Feature is not installed.
Note: Publish is successful without any error, but the application can't start.
Can anyone help me to resolve this error?
As I mentioned in comment, many factors can cause this generic error page, and it is difficult to find the root cause of the issue based on generic error message an error occurred while starting the application. For troubleshooting, you can use CaptureStartupErrors and the detailedErrors key to display details of startup exceptions.
Capture Startup Errors
new WebHostBuilder()
.CaptureStartupErrors(true)
Detailed Errors
new WebHostBuilder()
.UseSetting("detailedErrors", "true")

The pre-application start initialization method Start on type PreApplicationStartCode threw an exception

I have created a new WebMatrix-based website in Visual Studio 2013 Ultimate and added DB First EF ADO.NET to the site.
I have WebPages 3 installed, and .NET Framework is 4.5.
However, when I try to debug/Build the solution, it throws this error:
Error 1 The pre-application start initialization method Start on type
System.Web.WebPages.Administration.PreApplicationStartCode threw an
exception with the following error message: Attempt by security
transparent method
'System.Web.WebPages.Administration.SiteAdmin.RegisterAdminModule()'
to access security critical method
'System.Web.WebPages.ApplicationPart..ctor(System.Reflection.Assembly,
System.String)' failed..
The only result that appears for this error in Google is http://craigwilson.id.au/2014/03/18/azurewap-system-methodaccessexception-attempt-by-security-transparent-method/#comment-1308 however, the solution on that page is to install WebHelpers via Package Manager console. This solution did not fix it for me.
Why am I getting this error and how can I fix it?

Method not found on a successful build

Using VS2008 I made a build of a C# web application. The build succeeded but for some unknown reason, it did not include one of the methods that used to be there. I got the following error while trying to call a web service that trigger that method:
System.Web.Services.Protocols.SoapException: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.ApplicationException: UpdateDataObject failed with message: An error occurred (1000691):
Method "DeprovisionHandling2" could not be found in class "Assignments" --->
As soon as I generated a new build, the method was back there in the DLL and the web service worked as fine as before.
Anyone faced this strange problem? What could the reason be and how to make sure we avoid it in the future?
The build is made by TFS.
Thank you!

Categories