We want to compile and run the EOS SDK C++ and C# samples, so install all workloads and components listed above.
Error MSB8036 The Windows SDK version 10.0.17763.0 was not found. Install the required version of Windows SDK or change the SDK version in the project property pages or by right-clicking the solution and selecting "Retarget solution".
Alternatively, you can find these values by navigating to your product and clicking on Product Settings on the left menu. You will need the Product ID, Sandbox ID, Deployment ID, Client ID, and Client Secret.
Next, let's compile the C# SDK Samples.
<ItemGroup>
<Compile Include="..\SDK\Source\Core\**">
<Link>SDK\Core\%(RecursiveDir)%(Filename)%(Extension)</Link>
</Compile>
<Compile Include="..\SDK\Source\Generated\**">
<Link>SDK\Generated\%(RecursiveDir)%(Filename)%(Extension)</Link>
</Compile>
</ItemGroup>
public class ApplicationSettings
{
public string ProductId { get; private set; } = "";
public string ClientId { get; private set; } = "";
public string ClientSecret { get; private set; } = "";
public string SandboxId { get; private set; } = "";
public string DeploymentId { get; private set; } = "";
public PlatformInterface PlatformInterface { get; set; }
public void Initialize(Dictionary<string, string> commandLineArgs)
{
// Use command line arguments if passed
ProductId = commandLineArgs.ContainsKey("-productid") ? commandLineArgs.GetValueOrDefault("-productid") : ProductId;
SandboxId = commandLineArgs.ContainsKey("-sandboxid") ? commandLineArgs.GetValueOrDefault("-sandboxid") : SandboxId;
DeploymentId = commandLineArgs.ContainsKey("-deploymentid") ? commandLineArgs.GetValueOrDefault("-deploymentid") : DeploymentId;
ClientId = commandLineArgs.ContainsKey("-clientid") ? commandLineArgs.GetValueOrDefault("-clientid") : ClientId;
ClientSecret = commandLineArgs.ContainsKey("-clientsecret") ? commandLineArgs.GetValueOrDefault("-clientsecret") : ClientSecret;
}
}
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/ApplicationResources.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
public partial class App : Application
{
public static ApplicationSettings Settings { get; set; }
protected override void OnStartup(StartupEventArgs e)
{
// Get command line arguments (if any) to overwrite default settings
var commandLineArgsDict = new Dictionary<string, string>();
for (int index = 0; index < e.Args.Length; index += 2)
{
commandLineArgsDict.Add(e.Args[index], e.Args[index + 1]);
}
Settings = new ApplicationSettings();
Settings.Initialize(commandLineArgsDict);
base.OnStartup(e);
}
}
private DispatcherTimer updateTimer;
private const float updateFrequency = 1 / 30f;
public MainWindow()
{
InitializeComponent();
Closing += MainWindow_Closing;
}
private void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
App.Settings.PlatformInterface.Release();
App.Settings.PlatformInterface = null;
_ = PlatformInterface.Shutdown();
}
private void InitializeApplication()
{
var initializeOptions = new InitializeOptions()
{
ProductName = "EOSCSharpSample",
ProductVersion = "1.0.0"
};
var result = PlatformInterface.Initialize(initializeOptions);
Debug.WriteLine($"Initialize: {result}");
_ = LoggingInterface.SetLogLevel(LogCategory.AllCategories, LogLevel.Info);
_ = LoggingInterface.SetCallback((LogMessage message) => Debug.WriteLine($"[{message.Level}] {message.Category} - {message.Message}"));
var options = new Options()
{
ProductId = App.Settings.ProductId,
SandboxId = App.Settings.SandboxId,
ClientCredentials = new ClientCredentials()
{
ClientId = App.Settings.ClientId,
ClientSecret = App.Settings.ClientSecret
},
DeploymentId = App.Settings.DeploymentId,
Flags = PlatformFlags.DisableOverlay,
IsServer = false
};
PlatformInterface platformInterface = PlatformInterface.Create(options);
if (platformInterface == null)
{
Debug.WriteLine($"Failed to create platform. Ensure the relevant settings are set.");
}
App.Settings.PlatformInterface = platformInterface;
updateTimer = new DispatcherTimer(DispatcherPriority.Render)
{
Interval = new TimeSpan(0, 0, 0, 0, (int)(updateFrequency * 1000))
};
updateTimer.Tick += (sender, e) => Update(updateFrequency);
updateTimer.Start();
}
private void Update(float updateFrequency)
{
App.Settings.PlatformInterface?.Tick();
}
Initialize: Success
[Info] LogEOSOverlay - Overlay will not load, because it was explicitly disabled when creating the platform
[Info] LogEOSAntiCheat - [AntiCheatClient] Anti-cheat client not available. Verify that the game was started with the correct launcher if you intend to use it.
[Info] LogEOS - Updating Platform SDK Config, Time: 0.368525
[Info] LogEOS - SDK Config Platform Update Request Successful, Time: 0.821195
[Info] LogEOSAnalytics - Start Session (User: ...)
[Warning] LogEOSAnalytics - EOS SDK Analytics disabled for route [1].
[Info] LogEOS - Updating Product SDK Config, Time: 0.866974
[Info] LogEOSAnalytics - Start Session (User: ...)
[Info] LogEOS - SDK Config Product Update Request Successful, Time: 1.350656
[Info] LogEOS - SDK Config Data - Watermark: 82749226
[Info] LogEOS - ScheduleNextSDKConfigDataUpdate - Time: 1.350656, Update Interval: 325.699646
public abstract class BindableBase : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected bool SetProperty<T>(ref T storage, T value, [CallerMemberName] string propertyName = null)
{
if (Equals(storage, value)) return false;
storage = value;
OnPropertyChanged(propertyName);
return true;
}
protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
var eventHandler = PropertyChanged;
if (eventHandler != null)
eventHandler(this, new PropertyChangedEventArgs(propertyName));
}
}
public class CommandBase : ICommand
{
public virtual bool CanExecute(object parameter)
{
throw new NotImplementedException();
}
public virtual void Execute(object parameter)
{
throw new NotImplementedException();
}
public event EventHandler CanExecuteChanged;
public void RaiseCanExecuteChanged()
{
CanExecuteChanged?.Invoke(this, new EventArgs());
}
}
public class MainViewModel : BindableBase
{
private string _statusBarText;
public string StatusBarText
{
get { return _statusBarText; }
set { SetProperty(ref _statusBarText, value); }
}
public MainViewModel()
{
}
}
public static class ViewModelLocator
{
private static MainViewModel _main;
public static MainViewModel Main
{
get { return _main ??= new MainViewModel(); }
}
}
[Bindable(BindableSupport.Default)]
public class StringToBooleanConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null || !(value is string))
{
return false;
}
string stringValue = value as string;
return !string.IsNullOrWhiteSpace(stringValue.Trim());
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
[Bindable(BindableSupport.Default)]
public class StringToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null || !(value is string))
{
return Visibility.Collapsed;
}
string stringValue = value as string;
return string.IsNullOrWhiteSpace(stringValue.Trim()) ? Visibility.Collapsed : (object)Visibility.Visible;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:c="clr-namespace:EOSCSharpSample.Converters">
<c:StringToVisibilityConverter x:Key="StringToVisibilityConverter" />
<c:StringToBooleanConverter x:Key="StringToBooleanConverter" />
</ResourceDictionary>
You can find the code for this article below. Make sure you follow step 5 and 9 of the Setting up our C# solution section to add the SDK to the solution, and you edit ApplicationSettings.cs to include your SDK credentials.