views:

753

answers:

5

We created several custom web parts for Sharepoint 2007. They work fine-- however whenever they are loaded, we get an error in the event log saying:

"error initializing safe control - Assembly:...".

The assembly actually loads fine- Additionally, it is correctly listed in the web.config and GAC.

Any ideas about how to stop these (Phantom?) errors would be appreciated.

+2  A: 

You need to add a safecontrol entry to the web,config file, have a look at the following:

<SafeControls>
  <SafeControl
    Assembly = "Text"
    Namespace = "Text"
    Safe = "TRUE" | "FALSE"
    TypeName = "Text"/>
  ...
</SafeControls>

http://msdn.microsoft.com/en-us/library/ms413697.aspx

Daniel Pollard
A: 

Thanks but that part is there in the web config.. And it is being read correctly-- i.e. if I remove that line, the assembly doesn't load at all.

Is the TypeName set to some specific text? Or is it just the wildcard value (*)? My problem was that the TypeName was not a wildcard - when I changed it to the wildcard, the errors went away.
Kwirk
A: 

Can you provide more information about the error? Is there an error for each assembly?

Tundey
+1  A: 

Dennis,

Did you ever figure out what was going on with this?

Edit: I was having this problem too. It turned out that there was a problem with my Manifest.xml file. In the SafeControl tag for my assembly, I had the TypeName specifically defined. When I changed the TypeName to a wildcard value, the error messages in the event log stopped.

So to recap: This caused errors in the event log:
<SafeControl Assembly="AssemblyName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5bac12230d2e4a0a" Namespace="AssemblyName" TypeName="AssemblyName" Safe="True" />

This cleared them up:
<SafeControl Assembly="AssemblyName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5bac12230d2e4a0a" Namespace="AssemblyName" TypeName="*" Safe="True" />

Kwirk
+1  A: 

It sure does sound like you have a problem with your safe control entry. I would try:

Under the NameSpace and TypeName use "*". Using wildcards in namespace and typeName will register all classes in all namespaces in your assembly as safe. (You generally wouldn't want to do this with 3rd party tools.)

AdamBT