
Step 3: Set the Version Number and set up partially trusted callers
By default, the AssemblyVersion property of your project is set to increment each time you recompile your Web Part. A Web Part page identifies a Web Part with the version number that is specified in the web.config file. With the AssemblyVersion property set to increment, if you recompile your Web Part after importing it into a Web Part page, the Web Part framework will look for the version number you specified in the web.config file. If the version number does not match, an error will occur. To prevent the version number of your Web Part from incrementing each time you recompile, you need to set the version number in the AssemblyInfo file.
Since you are creating signed code, you must also tell your assembly to allow partially trusted code calls. By default, any strong-named assembly that does not explicitly opt in to its use by partially trusted code will be callable only by other assemblies that are granted full trust by security policy.
To set the version number and allow partially trusted callers
-
In Solution Explorer, double-click the AssemblyInfo file
-
Edit the line:
[assembly: AssemblyVersion(“1.0.*”)]
<Assembly: AssemblyVersion(“1.0.*”)>
so that it reads:
[assembly: AssemblyVersion(“1.0.0.0”)]
<Assembly: AssemblyVersion(“1.0.0.0”>
-
Add the following line to the top of the file:
-
Add the following line to the bottom of the file:
[assembly: AllowPartiallyTrustedCallers]
<Assembly: AllowPartiallyTrustedCallers()>