当我在IIS上发布aspnetcore5项目时,它出现了一个错误



当我在visual studio 2019中运行我的项目时是好的,但当我在IIS上发布我的项目后会出现错误。

An unhandled exception occurred while processing the request.
NullReferenceException: Object reference not set to an instance of an object.

我使用的是mediator an 5 Layers clean;我在启动时注册了MediatR,但错误没有解决。

services.AddMediatR(typeof(YarnSystemCommandDTO).GetTypeInfo().Assembly);
services.AddScoped(typeof(IGenericRepository<>), typeof(GenericRepository<>));

要调试这种情况,第一次机会异常的调用堆栈将非常有用。一个简单的方法是在应用程序的入口点引入一分钟的延迟,这样您就有时间连接到w3wp进程,以便在启动时捕获异常。确保";只是我的代码";已禁用。

问题是关于数据库连接和我在数据库中添加用户访问权限:'IIS APPPOOL\tqcApi'

相关内容

最新更新