7

I made a test SL5 OOB project and tried to build under x64 platform but I get the warning:

"Assembly generation -- Referenced assembly 'CommonLanguageRuntimeLibrary' targets a different processor".

and an error:

Error 2 Could not load file or assembly 'file:///C:\work\TestSilverlightOOB\TestSilverlightOOB\obj\x64\Debug\TestSilverlightOOB.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format. C:\Program Files (x86)\MSBuild\Microsoft\Silverlight\v5.0\Microsoft.Silverlight.Common.targets 214 9 TestSilverlightOOB

Same for WebHosted with RIA enabled.

underflow
  • 181
  • 1
  • 11
  • Is it building when you change CPU to x86 ? – Pogrindis Feb 23 '18 at 14:54
  • Yes, of course, and under AnyCpu also. – underflow Feb 27 '18 at 09:40
  • Can you please mention in your post what have you done before, to solve the issues, so we may rule out those possibilities? – Wilhelm Sorban Feb 28 '18 at 09:53
  • @WilhelmSorban I just made a new file project and then from Configuration Manager made a new x64 config and hit Build. – underflow Feb 28 '18 at 11:22
  • Sorry, I didn't express myself clearly. I meant to ask what possible fixes have you tried? Have you tried running VS as admin? Since the SL dependency is in Program Files folder, your application may not have rights to it. Also, the SL dependency is 32 bit (Program Files (x86)), and you are trying to run the application in 64 bit mode. – Wilhelm Sorban Feb 28 '18 at 12:09

2 Answers2

2

Finally the answer to the questions is no. Silverlight apps cannot be build as x64 apps.

The reason is the references from here

c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v5.0

are x86 and there is no x64 SDK for Silverlight 5

underflow
  • 181
  • 1
  • 11
  • Very nice of you to get the right answer, but create your own, and accept yours, instead! As a future reference, I also recommend when you post on SOF, be more specific about what you have researched, and the attempts you have made to solve the issue. Regards, your colleague – Wilhelm Sorban Feb 28 '18 at 22:52
1

Since it is running correctly in 32 bit mode, and since I see the error points to a SL library in the 32 bit Program files, while running in 64 bit mode, the most probable cause I see is the conflict between the two platforms.

Please try to get Silverlight from here: https://www.microsoft.com/getsilverlight/Get-Started/Install/Default

Hopefully, if you target x64 processors, if you have the above installed, it will find it automatically.

While doing a short research, I have also found this: https://social.msdn.microsoft.com/Forums/vstudio/en-US/20a742a1-b99c-4638-8590-9a9d6a95fb69/building-silverlight-project-using-msbuildexe?forum=msbuild

While not convenient, the accepted answer might be helpful.

Wilhelm Sorban
  • 1,012
  • 1
  • 17
  • 37