Activator.CreateInstance抛出参数'Type'的ArgumentNullException [英] Activator.CreateInstance throws ArgumentNullException for parameter 'Type'

查看:288
本文介绍了Activator.CreateInstance抛出参数'Type'的ArgumentNullException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近遇到了我的个人资料提供商的问题:它无法正确检索个人资料(请参见下面的错误)。它可以在本地运行,但是当我将由Web部署项目编译的代码放在服务器上时,将崩溃。

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.


值不能为null。
参数名称:类型
说明:在
执行
当前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.

Strack跟踪:

[ArgumentNullException:值不能为null。
参数名称:类型
System.Activator.CreateInstance(类型类型,布尔型非公共)+2796915
System.Web.Profile.ProfileBase.CreateMyInstance(字符串用户名,布尔型isAuthenticated)+76
System.Web.Profile.ProfileBase.Create(字符串用户名,布尔值已认证)+312

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

解决方案,但远非显而易见(请参阅下面的答案)。

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

推荐答案

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

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


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

Treat as library component (remove App_Code.Compiled file)

这篇关于Activator.CreateInstance抛出参数'Type'的ArgumentNullException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆