While deploying the Service Fabric Cluster, I got the below issue.
Connect-ServiceFabricCluster : An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B) At XXYYZZ(path of script):62 char:2 + Connect-ServiceFabricCluster @ConnectionParams + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Connect-ServiceFabricCluster], BadImageFormatException + FullyQualifiedErrorId : CreateClusterConnectionErrorId,Microsoft.ServiceFabric.Powershell.ConnectCluster
Actuall it was running perfectly when we installed required modules
https://www.microsoft.com/en-in/download/details.aspx?id=30679
http://www.microsoft.com/web/handlers/webpi.ashx?command=getinstallerredirect&appid=MicrosoftAzure-ServiceFabric-CoreSDK
But we wanted to install the service fabric cluster from the system, where system do not have the required Service Fabric Components(which are above ones). Now we are loading these components/modules/dll through the Import-Module command by placing the dll's in a particular folder and used the command called Import Module. May I know, how can I resolve this issue.
I'm doing the exact same thing and didn't want to install the Service Fabric SDK on our build system. After some trial and error I finally got it right: I've placed the necessary Service Fabric Tools and SDK files into source control, check those tools out during the build, and then import the PowerShell modules from both before calling Connect-ServiceFabricCluster. I realize that placing binaries and related files into VCS isn't a great solution: in the future I'd love to use something like Artifactory instead.
Here's the solution in detail.
First, put the necessary tools into VCS:
Second: Add the tools to your build
Third: in your PowerShell script import the tools and SDK modules (I'm assuming the Service Fabric tools and SDK are in a ServiceFabric sub-folder relative to the current working directory):
Import-Module ServiceFabric\Tools\Microsoft.ServiceFabric.Powershell.dll
Import-Module ServiceFabric\SDK\ServiceFabricSDK.psm1
Here are some final thoughts: I use a 64-bit flavor of Windows 7 and all of our build machines are 64-bit. I honestly don't know if a 32-bit version of the Service Fabric SDK and tools exists. At any rate you need to be sure you are using a 64-bit version of PowerShell. We use TeamCity and I explicitly set the Powershell run mode Bitness to x64.
The Deploy-FabricApplication.ps1 script that is included with Service Fabric projects attempts to load the Service Fabric SDK module by reading a registry key for the SDK path and then calling Import-Module. Since the build machines do not have the SDK installed I added a modified copy of this script to VCS as well, commented out the lines that read the registry and load the module, and then make use of the -UseExisingClusterConnection parameter.
User contributions licensed under CC BY-SA 3.0