How to solve warning "Referenced assembly targets a different processor than the application"

Viewed 45951

I have been able to build my windows form application that access databases in SQL Server. All parts of the application are able to access the server apart from the part where one can back up/restore a database. In this part I can not access the databases on the server and have come to believe it is because of these warnings. What do the followings exactly mean and how can I correct them?

Referenced assembly
  'c:\Program Files\Microsoft SQLServer\90\SDK\Assemblies\Microsoft.SqlServer.Replication.dll' 
  targets a different processor than the application

Referenced assembly
  'C:\Windows\assembly\GAC_32\Microsoft.SqlServer.BatchParser\9.0.242.0_89845dcd8080cc91\Microsoft.SqlServer.BatchParser.dll'
  targets a different processor than the application.
6 Answers

This error can also occur after a Windows 10 update if certain DLLs that you're using have been deregistered somehow. This is now the third time this has happened - and it causes normally fine CPU settings to appear broken.

For me this keeps happening with Microsoft.mshtml - every major Windows 10 update!! - including the April 2018.

Quick steps:

  • Open developer command prompt for visual studio (as administrator)
  • Run gacutil /l | find "Microsoft.mshtml"
  • Go to the folder C:\Windows\assembly\GAC\Microsoft.mshtml
  • Run dir and change to the directory
  • Run regasm Microsoft.mshtml.dll
  • Try to compile again

http://techninotes.blogspot.com/2016/08/fixing-cannot-find-wrapper-assembly-for.html

In my case: Referenced assembly '####, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' targets a different processor.

In VS2017 - Build - "Prefer 32 Bit" was checked. Unchecked, csc error removed.

Related