Error while using ServiceFabric in a WinForm App

92 views Asked by At

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

1

There are 1 answers

1
Alex AIT On

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