Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error with dropping web part -- not registered on this site as safe.

Status
Not open for further replies.

JBMadden

Programmer
Aug 8, 2003
1
US
I've found about five different tutorials on creating web part in C# in Visual Studio.NET. I have no problem creating the web part but I'm missing something about moving it to the SharePoint Server and droppping it on the page.

I'm getting the error:

A Web Part or Web Form Control on this Web Part Page cannot be displayed or imported because it is not registered on this site as safe.

after uploading the web part and trying to drop it on the page.

I've created the strong name with the sn.exe and I've added to my assembly.cs file: [assembly: AssemblyKeyFile("c:\\keypair.snk")] and then copied the keypair.snk to the c drive on the SharePoint Server. I've even referenced it other ways: "..\\..\\keypair.snk".

I've dropped my assembly into the C:\WINDOWS\assembly directory to determine the public token key and entered that into my dwp file:
<Assembly>SimpleWebPart, Version=1.0.0.1, culture=Neutral,
PublicKeyToken=463f397437b56b46</Assembly>

and I've added the assembly to the web.config file on the SharePoint Server:
<SafeControl Assembly=&quot;SimpleWebPart, Version=1.0.0.1, Culture=neutral, PublicKeyToken=463f397434346b46&quot; Namespace=&quot;MyWebParts&quot; TypeName=&quot;*&quot; Safe=&quot;True&quot; />

I've done this same procedure about five times with different methods of deployment and different simple beginner web part code: with a cab file, with the Wppackager.exe program, one with the Web Part Library in Visual Studio.NET, and once with a manual process. Each time the same results. When dropping the control onto the page I get that it isn't safe.

Can anyone tell me what I'm missing here? I've even tried dropping the assembly into the GAC but get the same results. We are using SharePoint 2003 on the server.

 
You are almost there!
I had the same problem and I found that I was changing the wrong web.config file.
I was changing the one in the Inetpub\ directory (as in the example) but the sharepoint web site I was trying to alter had its root somewhere else.
Check the 'home directory' tab in IIS for the website virtual directory and then alter the web.config file in there.
Also I found that I needed to use gacutil.exe to add my assembly to to the gac.
 
I am having the exact same problem, but I have went as far as looking at every single web.config file on the SPS server and placing a SafeControls entry in each of the web.config files that this was applicable to on the server. The only thing I know now to do is to use a packager to install the web part to see if this can hit everything that it needs. Does anyone have any other magic bullets?
 
I was working on building webparts last week. I got the same error message after modifying the config file. I found my issue was that I needed to modify the build output path in Visual Studio 2003 to be c:\inetpub\ That automatically puts the webpart assembly in the correct folder on the sharepoint server. You can copy the assembly to the folder if it has already been built as well.

To specify the build output path
1. In the Solution Explorer, right-click your project name (for example, SimpleWebPart), and the click Properties
2. Under configuration porperties | Build | Outputs, set the Output Pah to: C:\inetpub\
I found the information on page 2 of


-coremt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top