This article will help you:
Fixing web Parts From the Web Part Not Registered As a Safe Control Error
My "Working With the Web Part Templates" article series was written for SPS
Beta 2 and it worked great at the time. When Technical Refresh of Beta 2 was
released, some of the architecture of SPS changed. To do anything more than
the most basic things, you need to register your parts as safe and load them
in the GAC.
In your dwp, you need to change the block to include the public key token.
Here are the basic instructions:
1) Run the sn.exe utility to create a key for your assembly (the util is
somewhere under the Visual Studio path, you shoud may want to search for
it). The syntax should look like:
sn -k c:\key.snk
2) In the assembly Info file of your web part, change the version # listed
thre from 1.0.0.0 (or 1.0.0.*) to 1.0.0.1. Also under the PublicKeyFile
field (which is toward the bottom). Add in the quotes C:\\key.snk
3) Build your web part, take the DLL that was built and copy it to
C:\Windows\assembly (this is a GAC). Then right click the assembly and
choose properties. Copy the PublicKeyToken (and for the rest of the steps we
are going to pretend that it is 64bf77798fbca80 but you should use your own
when you follow the steps)
4) Go back to your Project and open the DWP file. Change the following:
<Assembly> AssemblyName </Assembly>
to
<Assembly AssemblyName, Version=1.0.0.1, Culture=Neutral,
PublicKeyToken=64bf77798fbca80 </Assembly>
5) Build the project. This should rebuild your CAB with the new dwp file.
6) When importing the cab, you want to use:
stsadm -o addwppack -filename filename.cab -globalinstall -force
The globalinstall parameter there is necessary becasue that will tell the
installed to add the part to the GAC and register it as safe in the
web.config file.
7) Run iisreset - when you install safe web parts to the cache, you need to
reset IIS before they will be available
8) (optional) before reinstalling new web parts, I usually run:
stsadm -o deletewppack -name filename.cab
just to make sure the old one is deleted first. Other say this isn't
necessary, which is probably true, but I like to do it just to be safe.
Once you have done those steps for your assembly, test to make sure the web
parts import. You should not see the safe controls error message now. Also,
once you have completed these steps and your parts successfully import, you
do not need to perform these steps again for this project. You can change
the code all you want and just follow steps 6-8 to delete and reinstall the
updated parts.
Please post questions in the discussion boards, or email me with comments
and concerns.