Click here to Skip to main content
15,886,026 members
Articles / Web Development / ASP.NET
Tip/Trick

Fixing ArgumentNullException When Using the ASP.NET Profile Feature in a Precompiled Site

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
8 Jun 2010CPOL 10.5K  
Essentially, leave 'Treat As Library Component Unchecked'

If you are seeing this error:

[ArgumentNullException: Value cannot be null.Parameter name: type]
System.Activator.CreateInstance(Type type, Boolean nonPublic)
System.Web.Profile.ProfileBase.CreateMyInstance(St ring username,Boolean isAuthenticated)
System.Web.Profile.ProfileBase.Create(String username, Boolean isAuthenticated)

And the Profile feature works on your development machine but not in production, there's a good chance that you're precompiling the website as a build release step.

To make sure the Profile feature keeps working, make sure that 'Treat As Library Component' is unchecked if using Web Redeployment Project. If you're using MSBUILD and the AspNetMerge Task, make sure the 'RemovedCompiledFiles' is set to false:

XML
<AspNetMerge
          ExePath="$(FrameworkSDKDir)bin" 
          ApplicationPath="$(TempBuildDir)"
          KeyFile="$(_FullKeyFile)"
          DelaySign="$(DelaySign)"
          Prefix="$(AssemblyPrefixName)"
          SingleAssemblyName="$(SingleAssemblyName)"
          Debug="$(DebugSymbols)"
          Nologo="$(NoLogo)"
          ContentAssemblyName="$(ContentAssemblyName)"
          ErrorStack="$(ErrorStack)"
          RemoveCompiledFiles="false"
          CopyAttributes="$(CopyAssemblyAttributes)" 
          AssemblyInfo="$(AssemblyInfoDll)" 
          MergeXmlDocs="$(MergeXmlDocs)" 
          ErrorLogFile="$(MergeErrorLogFile)" 
          />

If you are not using a Precompiled site, but you are using a custom provider, check to make sure the library that contains your provider has been deployed correctly!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Freestyle Interactive Ltd
United Kingdom United Kingdom
I'm a lead developer for Freestyle Interactive Ltd where we create many wonderful websites built on Microsofts ASP.Net and Ektron CMS.

I've been developing .Net applications (both Windows and Web) since 2002.

Comments and Discussions

 
-- There are no messages in this forum --