One way to get the PublicKeyToken is to use the sn.exe (strong name utility) that comes with .NET Framework.
Open the command prompt and change directory to directory that contains sn.exe. Type the following command to get the PublicKeyToken of your dll file.
sn -T yourdirectory\yourwebpart.dll
Get PublicKeyToken with sn.exe
WSS Web Part Tutorial
In this simple tutorial, you will see how to create a simple custom Web Part with Microsoft Visual Studio 2005. In this tutorial, I will create a simple web part called "Hello Sharepoint-Girl".
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.
WSS Alerts not working
When your user creates an alert they receive the Alert creation email but does not get Alerts emails when items are added or changed. Users able to receive the alert creation email indicates that the Outgoing email setting has been configured correctly. The Event Logs also not showing any error message.
If you are facing the above mentiond problem, try to check the Timer Job Definitions from the Central Administration Page. If you cannot see Immediate Alerts job in the Timer Job Definitions, then you have to do as follows:
1) Open Dos command prompt.
2) Browse to the directory that you can access stsadm.exe. It is usually stored in C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\bin
3) Type the the following 2 commands:
stsadm.exe -o setproperty -url http://sharepoint-girl.com -pn alerts-enabled -pv true
stsadm.exe -o setproperty -url http://sharepoint-girl.com -pn job-immediate-alerts -pv "every 5 minutes"
The 5 minutes here will cause the Timer to send out alerts email on every 5 minutes. This means that, even if you create the alerts to send email immediately, the email won't be sent out immediately. It will be delayed for up to 5 minutes.
WSS Search Service failed to start
You try to start WSS Search engine but received an unknown error. Unknown error cannot give you any clue what was wrong with the Search engine. Fortunately, you can check the error message from Window's Event Log.
1) At the Control Panel, select Administrative Tools --> Event Viewer.
2) Select Application. Double click on the Error that caused by Windows SharePoint Services v3.
If you receive the following error message:
CREATE DATABASE permission denied in database 'master'
Most probably is the User Account that you use to start the Application Pool for Sharepoint site has no permission to create database in SQL Server. WSS is not using the user name that you used to start the WSS Search service to create the database. Therefore, even if you use Administrator account as the Search Service account, you still won't be able to create the Search database.
To solve this problem, you can create the Search Database manually in the SQL Server and then grant necessary permission to the account that you used to start application pool in this databse. After you grant the necessary permission, try to start the Search service again.
IE 6 and IE 7 crashes while opening Office document in WSS or MOSS site
When you try open an office document from WSS 3.0 or MOSS 2007 site with Internet Explorer 6 or Internet Explorer 7, your IE crashes and need to be terminated. This problems occurs if you have programs from both Office 2003 and Office 2007 running on your computer.
I have heard people say that I only have Office 2003 (Word 2003, Excel 2003, Powerpoint 2003, Outlook 2003) running on my computer. I am not using Office 2007 but why my IE still crash. Think again carefully. Are you really not using any program from Office 2007 ?
How about the Sharepoint Designer 2007 ? Do you have Sharepoint Designer 2007 installed on your computer ? Many developers have forgotten that Sharepoint Designer 2007 is part of the Office 2007.
Microsoft realized this problem and has released hotfix to solve this problem. Just download the small hotfix and execute it. The crash problem will gone.
Description of the 2007 Office hotfix package: June 17, 2007