mbillard
mbillard

Reputation: 38872

Activator.CreateInstance throws ArgumentNullException for parameter 'Type'

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.

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 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

Hosted by imgur.com


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

Upvotes: 3

Views: 6307

Answers (3)

Eden Townsend
Eden Townsend

Reputation: 395

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.

Upvotes: 0

anon
anon

Reputation:

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

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".

Upvotes: 0

mbillard
mbillard

Reputation: 38872

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

Treat as library component (remove App_Code.Compiled file)

Upvotes: 2

Related Questions