Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Custom web part not working

  Asked By: Morgan    Date: Sep 17    Category: Sharepoint    Views: 9191

I built a web part that doesn't do anything except print "Hello
world". When I drag it to the screen I get this in the right pane
where the web parts are listed:

"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."

The web part installed OK via a cab file through stsadm and shows up.
It seemed to have added it to the web.config file for the site. FYI,
this is a brand new portal server out of the box.



4 Answers Found

Answer #1    Answered By: Terrell Bates     Answered On: Sep 17

you need to register the webpart in the web.config file  of
your SPS. Once it is rendered as safe, it should work in a webpart

There is a line in the web.config file already:

<SafeControl Assembly="DoNotCallList, Version=,
Culture=neutral, PublicKeyToken=7a0210290ce1d1ec"
Namespace="DoNotCallList" TypeName="*" Safe="True" />

Is there something else that needs to take place?

Is the web  Part in the GAC or the /bin? I've seen this behavior in the GAC
but haven't had a chance to research why. Deploying the DLL to the /bin
fixes the problem. As I said, I'm not sure why.

Make sure that you place this complete tag in your DWP file.

<Assembly>DoNotCallList, Version=,Culture=neutral, PublicKeyToken=7a0210290ce1d1ec</Assembly>

Answer #2    Answered By: Wilson Bryan     Answered On: Sep 17

It is not in the bin nor the GAC because this is a production server.
I've installed  a few commercial web  parts and didn't have to do
anything but install the cab  file and they are working.

I had rather not deal with the bin stuff if I can avoid it (since
commerial or other web parts  I download do not require doing that).

FYI, copying the DLL to the bin works, but it just doesn't make any
sense as to why other ones installed and didn't require that.

Answer #3    Answered By: Nathanael Wong     Answered On: Sep 17

All Web Parts must have their DLLs deployed where SharePoint can find them.
There are only three places that SharePoint (actually the .NET Framework)
looks: the /bin, the GAC, or a PrivatePath. The commercial Web Parts also
have to deploy their DLL in one of these three places, but they probably use
the GAC so they might not be easy to find.

Answer #4    Answered By: Todd Hamilton     Answered On: Sep 17

Add the webpart you r trying to deploy in the webpart gallery of the site

To Go the gallery follow site  Settings > Go to Site administration > Manage web  part gallery.

Select New Webpart. You will be displayed all the webparts that are listed  in the web.config safe control  list.

Choose the one you need to add and select Populate Gallery.

Once u have done this go to the homepage and add the webpart, u will not get the error anymore.

Didn't find what you were looking for? Find more on Custom web part not working Or get search suggestion and latest updates.