Posted by Administrator
While trying to use my custom layouts page, I received an exception that indicated that my custom class was not registered as a safecontrol in the web.config.
Process information:
Process ID: 5272
Process name: w3wp.exe
Account name: DEV\spAppPool
Exception information:
Exception type: HttpParseException
Exception message: Could not load type 'Capgemini.SharePoint.Pex.Example.Layouts.Capgemini.SharePoint.Pex.Example.@default'.
Cause
I was confused, didn't visual studio created the SafeControls elements for me? WSPBuilder did it for me in the past so why won't visual studio do it for me?
Solution
Actually it can but it doesn't by default, Microsoft provided a nice and easy visual studio interface for us. So here it goes...
1. Open package.package in your visual studio project
2. Notice the 3 tabs (Design,Advanced and Manifest), Click on the manifest tab
3. You’ll see that your SafeControl element is not listed in the manifest, if it does, than you don’t have to complete this tutorial because everything is already in place
4. Click on the Manifest tab
5. Provide the following code inside the Assembly Element
This results in
You'll notice that I’ve used 2 special elements in the xml
$SharePoint.Project.AssemblyFullName$ and
$SharePoint.Project.AssemblyFileNameWithoutExtension$.
These 2 parameters are new in visual studio 2010 SharePoint development. Replaceable parameters, or tokens, can be used inside project files to provide values for SharePoint solution items whose actual values are not known at design time. They are similar in function to the standard Visual Studio template tokens
Check the related link at the bottom of this post for the MSDN website.
More information regarding replaceable parameters
Name | Description |
|---|---|
$SharePoint.Project.FileName$ | The name of the containing project file, such as, "NewProj.csproj". |
$SharePoint.Project.FileNameWithoutExtension$ | The name of the containing project file without the file name extension. For example, "NewProj". |
$SharePoint.Project.AssemblyFullName$ | The display name (strong name) of the containing project’s output assembly. |
$SharePoint.Project.AssemblyFileName$ | The name of the containing project’s output assembly. |
$SharePoint.Project.AssemblyFileNameWithoutExtension$ | The name of the containing project’s output assembly, without the file name extension. |
$SharePoint.Project.AssemblyPublicKeyToken$ | The public key token of the containing project’s output assembly, converted to a string. (16-characters in "x2" hexadecimal format.) |
$SharePoint.Package.Name$ | The name of the containing package. |
$SharePoint.Package.FileName$ | The name of the containing package's definition file. |
$SharePoint.Package.FileNameWithoutExtension$ | The name (without extension) of the containing package's definition file. |
$SharePoint.Package.Id$ | The SharePoint ID for the containing package. If a feature is used in more than one package, then this value will change. |
$SharePoint.Feature.FileName$ | The name of the definition file of the containing feature, such as Feature1.feature. |
$SharePoint.Feature.FileNameWithoutExtension$ | The name of the feature definition file, without the file name extension. |
$SharePoint.Feature.DeploymentPath$ | The name of the folder that contains the feature in the package. This token equates to the "Deployment Path" property in the Feature Designer. An example value is, "Project1_Feature1". |
$SharePoint.Feature.Id$ | The SharePoint ID of the containing feature. This token, as with all feature-level tokens, can be used only by files included in a package via a feature, not added directly to a package outside of a feature. |
$SharePoint.ProjectItem.Name$ | The name of the project item (not its file name), as obtained from ISharePointProjectItem.Name. |
$SharePoint.Type. | The assembly qualified name of the type matching the GUID of the token. The format of the GUID is lowercase and corresponds to the Guid.ToString(“D”) format (that is, xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx). |
$SharePoint.Type. | The full name of the type matching the GUID in the token. The format of the GUID is lowercase and corresponds to the Guid.ToString(“D”) format (that is, xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx). |
Package interface
Good Luck!




( 3 / 899 )

Tom Van Gaever - Blog


]

Avatar






