Error message when you click "Calculate Permissions" for a Visual Studio 2008 ClickOnce application: "Calculating permissions failed"


When you click Calculate Permissions on the Security tab for a Microsoft Visual Studio 2008 ClickOnce application, the Calculate Permissions process may not run successfully. Additionally, you may receive the following error message:
Calculating permissions failed.
Could not load file or assembly 'AssemblyPath' or one of its dependencies. An attempt was made to load a program with an incorrect format.


This problem occurs when the Platform target property is set to x64.


To work around this problem, use one of the following methods.

Method 1

Change the value of the Platform target property to x86 or to Any CPU. To do this, follow these steps:
  1. In Solution Explorer, click the project name.
  2. On the Project menu, click ProjectName Properties.
  3. Click the Build tab, and then select one of the following items in the Platform target list:
    • x86
    • Any CPU
  4. Click the Security tab, and then click Calculate Permissions.
Note You should use Method 1 only if you are not using 64-bit-specific assemblies. If you use Option 1 when you are using 64-bit-specific assemblies, the Calculate Permissions process fails.

Method 2

Use the PermCalc.exe file to manually create the permissions for your assembly. To do this, follow these steps:
  1. Click Start, click Run, type cmd, and then click OK.
  2. Type the following command, and then press ENTER:
    cd DriveLetter:\ Program Files\Microsoft SDKs\Windows\v6.0A\bin\
  3. Type the following command, and then press ENTER:
    PermCalc –CleanCache "AssemblyPath"
  4. Locate and then open the XML file that the PermCalc.exe file created.
  5. Copy and then paste the contents of the XML file into the App.manifest file in your project.


Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

Article ID: 945357 - Last Review: Dec 13, 2007 - Revision: 1