Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Troubleshooting Web Parts and Deployment : Page 3

While SharePoint has become tremendously popular precisely because it makes so many laborious tasks so easy, deployment of Web parts can be surprisingly thorny. The trick lies in knowing what STSADM, the command line tool generally used for installing Web parts from a CAB file, is looking for and making sure it's all packaged up properly.


advertisement
Common Problems
Now that you have a foundation for how things work, in the following sections I'll tear apart common errors and what their causes are.

Installation
Here are some of the problems that you can run into when trying to install a Web part pack:

  • Can not connect to the configuration database—In this situation, though your SharePoint implementation is operational, when you run STSADM you get a message saying that it can't connect to the configuration database. Most of the time this is because the logged in user doesn't have access to the SQL Server. STSADM accesses its database directly so the user account must have access to the database. To solve this problem, use the RUNAS command to run a command prompt as the application pool's user identity. Run STSADM from that command prompt. If it works, you have a permissions problem. If not, you've got a mystery.
  • Missing files referenced in manifest.xml—There are two basic problems that lead to this. First, you didn't change the reference in manifest.xml after changing the name of the assembly or the DWP file. If neither of these resolves the problem, you may have added another file but not added that file to the CAB file. The most common occurrence of this is adding a new DWP file to the project but failing to set its properties such that its Build Action is set to Content. Most people set up the CAB file to include the primary output and content files from the Web part project. If the build action property isn't set to Content then the new DWP file won't get picked up.

Running
One of the most frustrating things about SharePoint is not being able to determine what the problem is when a Web part can't be displayed. Generally you get the message that the Web part isn't registered as safe but you may get a handful of other messages including that the Web part has caused an error. Here are a few things to check:

  • Wrap everything in a try/catch. Make sure that you don't allow exceptions to propagate back to SharePoint. Handling of exceptions propagated from a Web part isn't one of SharePoint's strengths. Make sure you're doing your own error handling in CreateChildControls, the constructor, and RenderWebPart, as well as other overridden methods that might throw an exception.
  • Verify that the DWP is referencing the right assembly and type—verify this by going out to the /wpcatalog directory. Check the name of the file and make sure that it matches the reference internally in the file—and the way that you've created your assembly. This should include checking version number and public keys.
  • Verify that all of the DLLs that the Web part assembly references are loadable. When in doubt put anything that the DLL needs in the GAC—at least temporarily to guarantee that they are loadable.
  • Install the Web part itself into the GAC. It's possible that there's a security permission that's missing which is causing an issue. Put the assembly in the GAC at least temporarily to make sure that it isn't a security issue. One problem that sometimes happens is that the referenced DLL is in the GAC but the Web part itself is not. This requires that the referenced component have the attribute AllowPartiallyTrustedCallers so that non-trusted assemblies can be loaded.
  • Set the Trust level in the web.config to Full; turning down security on the Web site may help make the Web part work—you can then work backward to determine what the security issue may be.
  • If you have complex properties in your Web part, make them simple; SharePoint occasionally gets unhappy with serializing complex types. Comment out the property or change it to a simple type, like a string, and have the property setter do the conversion to the internal type.
  • Try an IISRESET. Occasionally bad things happen.



SharePoint Web parts aren't the easiest things to troubleshoot, however, with a bit of knowledge and a bit of patience you can make them work.



Robert Bogue, MCSE (NT4/W2K), MCSA:Security, A+, Network+, Server+, I-Net+, IT Project+, E-Biz+, CDIA+ has contributed to more than 100 book projects and numerous other publishing projects. He was recently honored to become a Microsoft MVP for Microsoft Commerce Server and before that Microsoft Windows Servers-Networking. Robert blogs at http://www.thorprojects.com/blog.
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap