- Make sure the web part class that load the user control has the GUID attribute and the constructor sets the export mode to all.
2. Add the AllowPartiallyTrustedCallers Attribute to the AssemblyInfo.cs file of the web part project and all other DLL projects it is referencing.
Figure 2 - Marking the assembly with AllowPartiallyTrustedCallers attribute
3. Copy all the DLLs from the bin folder of the web part project to the _app_bin folder of your SharePoint web application. Make sure all the DLLs are signed.
Note: You should copy the .pdb files as well to be able to debug the user control code
Figure 3 - Bin folder for web application project referencing DLLs from other projects
Figure 4 - DLLs added to _app_bin folder of the web application
4. Edit the web.config file of the SharePoint web application as follows:
5. Add the web part assembly to the safe controls section.
Figure 5 - Adding the web part assembly to the safe controls
6. Add the web part assembly to the assemblies section.
Figure 6 - Adding the web part assembly to the assemblies section
7. Now create the .webpart file then add the web part to your SharePoint site web part gallery.
Figure 7 - The .webpart file
Print this post
No comments:
Post a Comment