This content is for SDK V4. For the latest version, see the V5 documentation.
Confirm that you meet the minimum requirements. (Prerequisites)
Install the Ditto SDK. (Installing Dependencies)
Set up your app permissions. (Configuring Permissions)
Add Ditto to your app. (Initializing Ditto)
(Optional) Declare a foreground service (Android only). (Declaring a Foreground Service)
Prerequisites
Following are the minimum requirements that must be met before attempting to install Ditto:- A .NET Standard 2.0 compatible installation (starting with 4.14.4; earlier 4.x releases require .NET Standard 2.1).
- .NET Framework 4.8 is supported starting with 4.14.4.
- .NET 8 or higher if you are targeting .NET MAUI
Installing Dependencies
To use the Ditto SDK in your project, you’ll need to install the appropriate NuGet package.If using a package manager other than NuGet, the official package manager for .NET, the command syntax to install Ditto may differ from the following snippet. For more information, see the official Nuget documentation > Ditto .NET
.NET Framework 4.8+ setup
Ditto supports .NET Framework 4.8 and 4.8.1 via thenetstandard2.0 asset shipped in Ditto 4.14.4 and later in the 4.x line. Earlier 4.x releases (4.14.3 and below) target netstandard2.1, which is not consumable from .NET Framework.
- PackageReference (SDK-style csproj)
- packages.config (classic WinForms / WPF / ASP.NET)
Install the
Ditto NuGet package and you are done. No additional steps are required..exe, install the Ditto package directly on the .exe (startup) project as well. Native DLLs do not propagate through <ProjectReference> chains in .NET Framework.
Architecture: the Ditto native DLL is Windows x64 only. Ensure your project has <PlatformTarget>x64</PlatformTarget> and <Prefer32Bit>false</Prefer32Bit>. Older WinForms templates default to “AnyCPU + Prefer 32-bit,” which loads as a 32-bit process and fails to load the x64 native DLL.
For a working reference, see the dotnet-winforms-net48 sample on GitHub.
Troubleshooting
-
System.DllNotFoundException: Unable to load DLL 'dittoffi'(HRESULT 0x8007007E): The native DLL is not in the runtime output directory of your.exe. Forpackages.configprojects, confirm the<Content Include>entry shown above is present in the.exeproject’s csproj (not just a referenced library) and that the path resolves to a real file on disk. ForPackageReferenceprojects, ensure<RuntimeIdentifier>win-x64</RuntimeIdentifier>is set on the.exeproject. -
System.BadImageFormatException(HRESULT 0x8007000B): The native DLL is being found, but its architecture does not match the process. Confirm your.exeproject has<PlatformTarget>x64</PlatformTarget>and<Prefer32Bit>false</Prefer32Bit>. Thedotnet-winforms-net48sample shows the correct settings.
Configuring Permissions
To set up your environment for your target platform:- iOS Target
- Android Target
- Mac Catalyst Target
For apps targeting iOS; for example, MAUI, once you’ve added the Ditto package dependency,
configure permissions and ensure your app continues syncing while running in the background,
including when the end-user device is locked, by enabling background modes.
Requesting Permissions at Runtime
In addition to being declared, some permissions need to be requested from the user at runtime. To ensure your app has the required permissions for sync, use theDittoSyncPermissions helper class from the Ditto SDK.
This helper class simplifies the process of requesting end-user permissions at runtime with a single method call for all necessary permissions.
Ensure StartSync() is invoked after permissions have been requested.
C#
Initializing Ditto
Once you’ve installed the Ditto SDK, set the debug level you want Ditto to log messages for, create a new Ditto identity, and set up Ditto exception handling for data sync operations:C#
Declaring a Foreground Service (Android Only)
A foreground service allows your app to continue syncing data with Ditto while running in the background. A foreground service is not required to use Ditto, but without it your app will stop syncing whenever it is in the background. To declare the foreground service, add the following to yourAndroidManifest.xml:
small_app_icon drawable must be monochrome white.
The foreground service will be automatically started and stopped on startSync() and stopSync(), respectively.