0

I have microservices which are made in ASP.NET MVC. I need to provide testers with a WinForm App that they are going to use to upload files via the service however, when I use a class that is from the assembly Microsoft.ServiceFabric in my WinForm app, I get the following exception:

Could not load file or assembly 'Microsoft.ServiceFabric.Services, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. An attempt was made to load a program with an incorrect format.

I made sure that I have all of the same Nuget Packages that I use to talk with ServiceFabric in my Microservice and the project compiles properly. Does anybody have a clue about what could be the issue?

Thanks a lot,

Claude

Riv
  • 1,849
  • 1
  • 16
  • 16
Claude Roy
  • 147
  • 2
  • 5

1 Answers1

0

My first guess would be that your application targets anyCPU and the ServiceFabric assemblies are x64 only.

Also: I strongly suspect that you don't need the dependency to ServiceFabric in the first place. There is no reason for it to be in a WinForms application. Use something like HttpClient to call your Microservice.

You can also possibly use fuslog to check the exact binding error.

https://learn.microsoft.com/en-us/dotnet/framework/tools/fuslogvw-exe-assembly-binding-log-viewer

Alex AIT
  • 17,361
  • 3
  • 36
  • 73
  • Thanks a lot, it, in fact, turned out that I could use the WebClient class instead because even when I changed it to x64, I was getting other Exceptions so it seems some Service Fabric classes can't be used with Winforms. – Claude Roy Sep 14 '17 at 15:46