1) Launch Visual Studio 2005.
2) Select File --> New --> Project.
3) Select C# under Project Type.
4) Select Class Library under Visual Studio Installed templates.
5) Type HelloSharepointGirl in the Name textbox.
6) Select a location in your hard drive.
7) Click on the OK Button to create the HelloSharepointGirl web part.
8) Rename the Class1.cs source file to HelloSharepointGirl.cs
9) Right-click on the Reference foler in the Solution Explorer and the select Add Reference...
10) In the .NET tab, select System.Web and then click on the OK button to add the reference.
11) Replace the code in the HelloSharepointGirl.cs file with the following code.
12) In the Solution Explorer, right-click on the Properties folder and then select Open.
13) Select the Signing tab.
14) Check the Sign the Assembly checkbox.
15) Select New in the Choose a strong name file..
16) Type a desired name in the key file name.
17) Click on the OK button. Now, Visual Studio will sign your assembly with Strong Name whenever you compile the project.
18) Click on Build --> Build Solution.
19) If no error returned by the compiler, you can proceed to copy the DLL to the bin directory of your WSS site (C:\Inetpub\wwwroot\wss\VirtualDirectories\80\bin OR other directories depending on your setup).
20) Modify the Web.Config file for the WSS site to declare the custom web part as a safe control by adding the following code within the <SafeControls> tag.
<SafeControl Assembly="HelloSharepointGirl, Version=1.0.0.0, Culture=neutral, PublicKeyToken=162a44794eb4da93" Namespace="HelloSharepointGirl" TypeName="*" Safe="True" AllowRemoteDesigner="True" />
Note:
Please do not copy the PublicKeyToken in this example. You should have a different PublicKeyToken than the one shown in the example. You can get the PublicKeyToken with the sn.exe (strong name utility). Get PublicKeyToken with sn.exe.
21) Open you WSS site and then click on Site Actions --> Site Settings.
22) Click on the Web Parts link under the Galleries section.
23) Click on the New button.
24) Check the HelloSharepointGirl web part to select it and then click on the Populate Gallery button.
25) Now, you can add the HelloSharepointGirl web part to your site.
15 comments:
Thanks..
but when i press Populate Gallery button a new webpart was created and when i clicked on that i got an error page saying --
Assemblies that implement ASP.NET Web Parts and are installed into a partially trusted location, such as the bin directory, must be compiled with the AllowPartiallyTrustedCallersAttribute set for import to succeed
please help !!
Hey i got the solution :) --
Add the code statements using System.Security; and [assembly: AllowPartiallyTrustedCallers] to your AssemblyInfo.cs file.
Every thing goes fine but when I am trying to add this new webpart it is not in the list of Web Part Gallery.
I dont know what to do?
I have the same problem like Sohail Raza..Someone can help us?
check that the PublicKeyToken=162a44794eb4da93" is the same
the public key may be different, check in the GAC or use Red Gate's Reflector
Nice !!!!!!!!
Create Custom SharePoint WebParts, it is simple.
Try this too,
Custom SharePoint
WebParts
Who knows where to download XRumer 5.0 Palladium?
Help, please. All recommend this program to effectively advertise on the Internet, this is the best program!
AllwPartiallyTrusted error
Change:TypeName="HelloSharepointGirl"
Thanks a lot.. you saved my time !!!
In step 20, please change the PublicKeyToken accordingly.You should have your own PublicTokenKey. You cannot use 162a44794eb4da93 as your token key.
if you're doing this tutorial in VB, rather than C#, you have to be careful about the namespace. Either: 1 - don't enclose the class in a namespace, 2 - empty the root namespace in the myproject/application settings, or 3 - in your safecontrol tag use HelloSharepointGirl.HelloSharepointGirl as the namespace.
Hi
Thank you veru much.. now i am able to understand and work with sharepoint.This will be very useful for the beginners.
Hello and thank you for this wonderful tutorial!
But when I go to build my solution, it fails and gives me this error:
------ Build started: Project: HelloSharepointGirl, Configuration: Debug Any CPU ------
D:\Users\HGEORGE\Desktop\HelloSharepointGirl\HelloSharepointGirl\Hello SharepointGirl.cs(12,33): error CS0115: 'HelloSharepointGirl.HelloSharepointGirl.RednerContents(System.Web.UI.HtmlTextWriter)': no suitable method found to override
Compile complete -- 1 errors, 0 warnings
Build started 9/28/2011 9:54:28 AM.
GenerateTargetFrameworkMonikerAttribute:
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
CoreCompile:
D:\Windows\Microsoft.NET\Framework\v4.0.30319\Csc.exe /noconfig /nowarn:1701,1702 /nostdlib+ /errorreport:prompt /warn:4 /define:DEBUG;TRACE /reference:"D:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Microsoft.CSharp.dll" /reference:"D:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\mscorlib.dll" /reference:"D:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Core.dll" /reference:"D:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Data.DataSetExtensions.dll" /reference:"D:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Data.dll" /reference:"D:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.dll" /reference:"D:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Web.dll" /reference:"D:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Xml.dll" /reference:"D:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Xml.Linq.dll" /debug+ /debug:full /filealign:512 /keyfile:HelloSharepointGirl.snk /optimize- /out:obj\Debug\HelloSharepointGirl.dll /target:library "Hello SharepointGirl.cs" Properties\AssemblyInfo.cs "D:\Users\HGEORGE\AppData\Local\Temp\.NETFramework,Version=v4.0.AssemblyAttributes.cs"
Build FAILED.
Time Elapsed 00:00:00.14
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========
In response to my earlier comment:
I took out "override" and it builds now. No suitable method was found to override the RenderContent method. (I'm very new to C#)
Post a Comment