Partager via


XBAP:Reference in the manifest does not match the identity of the downloaded assembly

Any ClickOnce (browser based XBAP) Application fails on x86 operating systems with the below error message:

An exception occurred while downloading the application. Following failure messages were detected:
+ Reference in the manifest does not match the identity of the downloaded assembly WpfBrowserApplication1.exe.

- Stack trace:
at System.Deployment.Application.DownloadManager.ProcessDownloadedFile(Object sender, DownloadEventArgs e)
at System.Deployment.Application.FileDownloader.DownloadModifiedEventHandler.Invoke(Object sender, DownloadEventArgs e)
at System.Deployment.Application.FileDownloader.OnModified()
at System.Deployment.Application.SystemNetDownloader.DownloadSingleFile(DownloadQueueItem next)
at System.Deployment.Application.SystemNetDownloader.DownloadAllFiles()
at System.Deployment.Application.FileDownloader.Download(SubscriptionState subState)
at System.Deployment.Application.DownloadManager.DownloadDependencies(SubscriptionState subState, AssemblyManifest deployManifest, AssemblyManifest appManifest, Uri sourceUriBase, String targetDirectory, String group, IDownloadNotification notification, DownloadOptions options)
at System.Deployment.Application.DeploymentManager.SynchronizeCore(Boolean blocking)
at System.Deployment.Application.DeploymentManager.SynchronizeAsyncWorker()

I have already posted an another blog post on the same issue but it is applicable for a different scenario. The current issue does not occur on X64 OSs. Even, I created an exact similar sample XBAP application on my system and compared the application and deployment manifest files to check if there is any mismatch identity. But there was no mismatch. Hence, I reviewed the repro package using Visual Studio IDE and identified the root cause. The summary is mentioned below:

The repro CSPROJ file (WpfBrowserApplication.csproj) has an invalid entry, which generates binary that is not supported.

Here is the entry: <Prefer32Bit>true</Prefer32Bit>

If you create a new project and select .Net 4.0 as target, you will notice in project properties that a check box “Prefer 32-bit”, on the build tab, is greyed out – not selectable. It seems that the CSPROJ file was modified outside of VS and this flag was set inappropriately..

As per the MSDN doc, this Prefer32-bit check box is available only if all of the following conditions are true:

•On the Compile Page, the Target CPU list is set to Any CPU.
•On the Application Page, the Application type list specifies that the project is an application.
•On the Application Page, the Target framework list specifies the .NET Framework 4.5.

So the summary is that the Prefer32-bit check box shouldn’t be selected for building .net framework 4.0 applications as it is designed for .net framework 4.5. The resolution would be to manually edit the csproj file and remove all entries of "<Prefer32Bit>true</Prefer32Bit>" element or change its value to false like <Prefer32Bit>false</Prefer32Bit>

Note: If the Prefer32-bit check box is selected, the application runs as a 32-bit application on both 32-bit and 64-bit versions of Windows. Otherwise, the application runs as a 32-bit application on 32-bit versions of Windows and as a 64-bit application on 64-bit versions of Windows.

Running as a 64-bit application doubles the pointer size, and it can cause compatibility problems with libraries that are exclusively 32-bit. It makes sense to run an application as 64-bit only if it runs significantly faster or needs more than 4 GB of memory