Activator.CreateInstance为参数'Type'抛出ArgumentNullException

时间:2021-09-19 17:02:52

I recently encountered a problem with my Profile provider: it wouldn't retrieve profiles correctly (see error below). It worked locally, but when I put the code compiled by a Web Deployment project on a server it would crash.

我最近遇到了我的配置文件提供程序的问题:它无法正确检索配置文件(请参阅下面的错误)。它在本地工作,但是当我将Web部署项目编译的代码放在服务器上时,它会崩溃。

Value cannot be null. Parameter name: type 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.

值不能为空。参数名称:type描述:执行当前Web请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。

Strack Trace:
[ArgumentNullException: Value cannot be null. Parameter name: type] System.Activator.CreateInstance(Type type, Boolean nonPublic) +2796915 System.Web.Profile.ProfileBase.CreateMyInstance(String username, Boolean isAuthenticated) +76 System.Web.Profile.ProfileBase.Create(String username, Boolean isAuthenticated) +312

Strack Trace:[ArgumentNullException:Value不能为null。参数名称:type] System.Activator.CreateInstance(Type type,Boolean nonPublic)+2796915 System.Web.Profile.ProfileBase.CreateMyInstance(String username,Boolean isAuthenticated)+76 System.Web.Profile.ProfileBase.Create(String username, Boolean isAuthenticated)+312

Activator.CreateInstance为参数'Type'抛出ArgumentNullException


I found the solution, but it's far from being obvious (see my answer below).

我找到了解决方案,但它远非明显(请参阅下面的答案)。

3 个解决方案

#1


The solution to my error was to uncheck this option from the Web Deployment project:

我的错误的解决方案是从Web部署项目取消选中此选项:

Treat as library component (remove App_Code.Compiled file)

视为库组件(删除App_Code.Compiled文件)

#2


Simply building the web deployment project again after the checkbox change is sometimes not sufficient.

简单地在复选框更改后再次构建Web部署项目有时是不够的。

You should rebuild the web site, or clean the ASP.NET temporary ASP.NET Files folder, usually located in "%WINDIR%Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files".

您应该重建该网站,或清理ASP.NET临时ASP.NET文件夹,通常位于“%WINDIR%Microsoft.NET \ Framework \ v2.0.50727 \ Temporary ASP.NET Files”中。

#3


I've recently experienced this problem and it turned out to be a missing dependency. Using the fuslogvw.exe tool provided with visual studio finally identified the problem.

我最近遇到过这个问题,结果证明这是一个缺失的依赖。使用visual studio提供的fuslogvw.exe工具最终确定了问题。

#1


The solution to my error was to uncheck this option from the Web Deployment project:

我的错误的解决方案是从Web部署项目取消选中此选项:

Treat as library component (remove App_Code.Compiled file)

视为库组件(删除App_Code.Compiled文件)

#2


Simply building the web deployment project again after the checkbox change is sometimes not sufficient.

简单地在复选框更改后再次构建Web部署项目有时是不够的。

You should rebuild the web site, or clean the ASP.NET temporary ASP.NET Files folder, usually located in "%WINDIR%Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files".

您应该重建该网站,或清理ASP.NET临时ASP.NET文件夹,通常位于“%WINDIR%Microsoft.NET \ Framework \ v2.0.50727 \ Temporary ASP.NET Files”中。

#3


I've recently experienced this problem and it turned out to be a missing dependency. Using the fuslogvw.exe tool provided with visual studio finally identified the problem.

我最近遇到过这个问题,结果证明这是一个缺失的依赖。使用visual studio提供的fuslogvw.exe工具最终确定了问题。