Skip to content

Fix SFBinaryLoader initialization in service-fabric-services-inside-containers.md #266

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,23 @@ This document provides guidance to get your service running inside a Windows con

2. Add class [SFBinaryLoader.cs](https://github.com/Azure/service-fabric-scripts-and-templates/blob/master/code/SFBinaryLoaderForContainers/SFBinaryLoader.cs) to your project. The code in this class is a helper to correctly load the Service Fabric runtime binaries inside your application when running inside a container.

3. For each code package you would like to containerize, initialize the loader at the program entry point. Add the static constructor shown in the following code snippet to your program entry point file.
3. For each code package you would like to containerize, initialize the loader at the program entry point. Add a new Main function to your Program.cs and rename the old Main to RealMain, like in the example below. This is required to delay loading any Service Fabric dependencies until the SFBinaryLoader is initialized.

```csharp
namespace MyApplication
{
internal static class Program
{
static Program()
private static void Main()
{
SFBinaryLoader.Initialize();
RealMain();
}

/// <summary>
/// This is the entry point of the service host process.
/// </summary>
private static void Main()
private static void RealMain()
{
```

Expand Down