Dealing with complicated or uncompiled webparts...
by, 21st May 2009 at 08:40 AM (1379 Views)
Firstly, thanks to EduTech... we have been working together for a little while on Sharepoint projects. This post is the result of a remote session we did, where I was dealing with some PITA webparts!!!
Read and enjoy... and beware of the gotchas!
Take the scenario - you have a webpart you want to install. You download it, and it is just a .dll and a .webpart. Grrrrr you will think, how the hell do we get that one installed...
First - I'm going to drop the dlls in the GAC [Global Assembly Catalog/Cache depending where you read], but show the two different places you can use. Then you need toregister the controls in the web.config. Finally, you can upload the webpart and add it to a page.
The two GAC places which we need are C:\WINDOWS\ASSEMBLY, but you cannot put files in here directly on the same system. You must either do this remotely, or via unc path... (ie. \\servernamehere\C$\Windows\Assembly
There you can see what the GAC looks like..., and you can also drop dlls in here and they auto register. If you tried to do this via C:\Wind...\Ass... it wouuld throw a proper hissy fit at you!!! LOL
But... this is not the best way of doing it - as its not very secure. I prefer (so long as the developer of the webpart/solution has program'd well - using the bin directory of the sharepoint web virtual directory. Useful to know how to use the main GAC incase bin doesnt work. You can find the path to your virtual directory from IIS, by selecting Properties, then Home Directory [IIS6], or click Sites, then select Features View [IIS7].
Navigate to this via Windows Explorer, and go into the BIN folder. You may have other .dlls here already if you have other solutions/webparts installed. Simply copy your new webpart .dll here.
This next bit comes with a serious health warning.... editing the web.config...
ou can properly screw this one up - so be seriously careful. By screw up - i mean get IIS in a permanent loop. Any editing of this file automatically recyles IIS worker processes.
What Ihave highlighed is that when you do somehting (eg add a webpart, activate/deactivate a solution in central management or via stsadmin, it automatically generates a web*[long date/time}*.bak file, which is just a renamed web.config file - so relatively easy to restore/go back if worst comes to worst. However, we are doing a "maunal" so we have to do it ourselves...easier if you keep to the format...
Always use notepad (wordpad or spd will bugger the line breaks!) or notepad ++ (which can do xml layout checking... as although it is a .config it is really xml
Safe controls are near the top thankfully - and I usually add to the end of the last entry...
An example <Safe Control> looks like...
Simple... once you get used to it... but like I said - be careful. Hitting save has cycled IIS - we we will wait a mo for it to come back... so we can continue...Code:<SafeControl Assembly="WebpartName, Version=WebpartVersion, Culture=neutral, PublicKeyToken=1a4d7592bb8c741f" Namespace="WebpartNamespace" TypeName="*" Safe="True" />
Right - lets head into the sharepoint website, as we can add the WP now and put it on a page. as this is simply a webpart not a solution - you do not need to activate it.
Go to Site Actions > All Site Settings > Webparts (in galleries column) of your top level website. Click upload, point at the .webpart or .dwp depending on what you have and job done. Then just add it to a page like you would any other time.
Need any help - shout! Remote help available... :-)
Total Trackbacks 0