I was reviewing a SharePoint solution and found that a web part inside that solution has poor naming conventions so I decide to rename the web parts for giving the proper names to them.
I changed the necessary references in different files of web part (I’ll mention them in a separate blog post). Now after renaming the web part I deployed it on site and then tried to add it in a web part page and it simply throws me the error.
“Type is not registered as safe“. Well at first glance I decided to see me safe controls entries inside my site’s web.config file and I was right that namespace part was wrong in web.config file. It was pointing to earlier namespace and class name. Humnnnn so if I changed this entry manually then it works fine but I need to automate the deployment process and I wanted to write the correct safe controls entries inside web.config whenever we deploy the web part. Well so question arises where to set my safe control entries inside my SharePoint solution. Well after analysing that I came to the solution. So below are the steps described for that:
1. Open your SharePoint web part project inside visual studio 2010.
2. Select the web part folder for which you want to change the safe control entries in web.config file.
3. Press F4 to open properties window (I am not talking here for property page.).
4. In properties windows there is last entry of properties displaying as “Safe Control Entries“
5. Click on the eclipse sign in front of “Safe Control Entries” value.
6. Inside “Safe Control Entries” pop up window, check for Namespace properties inside SafeControlEntry1 properties panel.
7. Change value of namespace property according to your namespace and class and click ok.
8. Save and build the solution and deploy it again.
9. Now after successful deployment check web.config of site and voilà you’ll find the correct safe type entries of your web part.
Happy Share Pointing J
Microsoft made the excellent integration of SharePoint with Visual Studio 2010. Good to see that.
In my next blogs I’ll come with these types of enhancements that visual studio provides for SharePoint 2010.