Original Url: http://forums.l-space-design.com/blogs/day_of_the_developer/archive/2006/08/12/223.aspx
I thought the "Web Deployment" addin for VS 2005 was great. Until I used it on a site using profiles.
Now I get (in production only) the following exception:
Message: Value cannot be null.
Parameter name: type
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Web.Profile.ProfileBase.CreateMyInstance(String username, Boolean isAuthenticated)
at System.Web.Profile.ProfileBase.Create(String username, Boolean isAuthenticated)
Here is the code for CreateMyInstance
private static ProfileBase CreateMyInstance(string username, bool isAuthenticated)
type1 = BuildManager.GetProfileType();
type1 = ProfileBase.InheritsFromType;
ProfileBase base1 = (ProfileBase) Activator.CreateInstance(type1);
The bold line is where the exception must be thrown.
Much hunting and searching through "InheritsFromType" makes me think that it's got confused because of the new assemly name. Nothing is fixing it though.
Guess what. HostingEnvironment.IsHosted returns TRUE
public static bool IsHosted
return (HostingEnvironment._theHostingEnvironment != null);
So BuildManager.GetProfileType is at fault, or IsHosted should be returning false.
It returns true in my testing under IIS, so it must be GetProfileType that is at fault.
That's confirmed. BuildManager.GetProfileType() is returning null.
Now to find out why.
BuildManager.CodeAssemblies also returns null.
That gets assigned any time that CompileCodeDirectory successfully builds an assembly based on a directory.
That is called (indirectly) multiple times from EnsureTopLevelFilesCompiled() unless an exception occurs (which is not reported to me, and should be). EnsureTopLevelFilesCompiled() is called when GetProfileType() is called.
All of which implies that CompileCodeDirectory fails in some way.
If the bin directory contains this file:
Then it works. That means in the "Web Deployment" properties, uncheck "Treat as library component"
But that's not going to help if I need to merge this set of code with another set on the same website unless you can merge multiple versions of that file into a single file.
Still, it will do for now.