SafeControl Registration in WSS Solutions

While getting ready for the South Florida CodeCamp session on WSS Solution Framework, I've noticed an interesting feature of the deployment mechanism related to the registration of SafeControls. Prior to this little discovery I was using Lutz Roeder's .NET Reflector to obtain the full assembly name including version and public token. It turns out that in the WSS Solution Framework we only need to specify the name of the assembly. The framework will automatically detect that the assembly is strongly signed and fill in the Assembly attribute of the SafeControl element with the strong name of the assembly in the web.config entry. For example, if we specify in manifest.xml:

<Assembly DeploymentTarget="WebApplication" Location="myassembly.dll">
<SafeControls>
<SafeControl Namespace="mynamespace" TypeName="*" Safe="True" />
</SafeControls>
</Assembly>

In the web.config file it'll be resolved to:

<SafeControl Assembly="myassembly, Version=1.0.0.3, Culture=neutral, PublicKeyToken=b62731c11ae57915" Namespace="mynamespace" TypeName="*" Safe="True" />

This saves some time updating the solution manifest.xml file.

Dovizhdane!

Comments