Codebender
not the last of his kind
not the last of his kind
Jun 14th
Last time I wrote that the stsadm -o copyappbincontent command didn’t work if you had installed Office 2010 on the same machine with your SharePoint 2007. Later I found the same problem on more scenarios:
stsadm -o copyappbincontent command.psconfig command or running the SharePoint Products and Technologies Configuration Wizard application.upgrade.log file is missing.When you perform any of those operation, you will get the following error message:
One or more types failed to load. Please refer to the upgrade log for more details.
The message told you to refer to the upgrade log. Ironically, the upgrade.log file is missing from the logs folder.
Previously, I thought the solution is uninstall the whole Office 2010 suite. But apparently, uninstalling InfoPath 2010 is enough to solve the problem.
Jun 8th
Working with anonymous SharePoint sites can be tricky sometimes. If you’re not careful, your customization codes (Web parts, custom controls, custom pages, etc.) can popup the login dialog box to anonymous users. As anonymous users they don’t have a user account, so obviously they won’t be able to enter their user ID and password. Or it simply produces an error page that either way, prevents anonymous users from accessing your site.
This post addresses some common coding issues when you work with anonymous SharePoint sites, so you can avoid it earlier.
How to check whether the current user is an anonymous user? I may have overlooked it, but as far as I know there is no built-in API methods for this purpose. Fortunately it’s very easy and terse. You can test the value of SPContext.Current.Web.CurrentUser. If it is null then it is accessed by an anonymous user. Here is a sample code:
if (SPContext.Current.Web.CurrentUser == null) { // Anonymous user section } else { // Authenticated user section }
SPWeb.CurrentUserAs described on the previous point, when an anonymous user is accessing a Site, the value of SPContext.Current.Web.CurrentUser will always be null. Double-check whenever you are using the property. Always make sure that you have checked for the null value, or you will end up getting the nasty “System.NullReferenceException – Object reference not set to an instance of an object.” exception.
It is an obvious yet easily overlooked one. It is a common practice to utilize the UserProfile API to store user’s personalization. Since an anonymous user does not have a user profile, provide another mean to store his/her personalization data. It could be SharePoint lists, database tables, files, or even browser cookies.
I’m referring to the API under the Microsoft.SharePoint.Publishing assembly and namespace. I haven’t checked all of the API members, but not all will work with anonymous users. For example, the PublishingWeb.IsPublishingWeb(SPWeb web) works, but the PublishingWeb.GetPublishingWeb(SPWeb web) doesn’t. In fact, it will prompt the anonymous user to login by entering the user ID and password. The workaround is get an elevated SPWeb instance that has the System Account’s credential and then use the GetPublishingWeb() method on that instance. The following snippet illustrates it:
var currentWeb = SPContext.Curent.Web; // the method is available to anonymous users if (PublishingWeb.IsPublishingWeb(currentWeb)) { SPSecurity.RunWithElevatedPrivileges(delegate() { using (var site = new SPSite(curentWeb.Url)) { using (var web = site.OpenWeb()) { // the method is not available to anonymous users var pubWeb = PublishingWeb.GetPublishingWeb(web); // Do something with pubWeb } } }); }
I will update this post when I find more things related to anonymous SharePoint sites. Please leave a comment if you have something to contribute, too.
May 25th
*Update: InfoPath 2010 is the real cause, please check this post.
I love Microsoft Office 2010. It’s more beautiful and faster than Microsoft Office 2007. I downloaded and installed the product immediately after its RTM version arrived on the MSDN download page. I even installed it on my Windows Server 2003 virtual machine that runs MOSS 2007. At first, I thought it worked great.
Apparently it was not a good idea. Later I realized something was broken. As the VM is my SharePoint sandbox, soon I encountered a problem when I was playing with it. That happened when I executed an stsadm command, a rather simple one actually:
stsadm -o copyappbincontent
But it failed with the following error:
One or more types failed to load. Please refer to the upgrade log for more details.
I found nothing useful in the event log and SharePoint logs to fix this issue. So I googled it and found this thread on TechNet. It was suggested that Office 2010 was the problem and the solution was to uninstall it. Unfortunately it was not explained what the root cause of the issue was. I don’t want to uninstall the whole product just to fix this issue. For now, I can just copy the resource files manually to the App_GlobalResources folder in my virtual directory instead of using the stsadm -o copyappbincontent command. Hopefully there won’t be more issues because of Office 2010 and Microsoft would fix the issue soon.
Recent Comments