Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

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

0.00/5 (No votes)
8 Jun 2010 1  
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:

<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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here