diff --git a/Duplicati/Library/Localization/Duplicati.Library.Localization.csproj b/Duplicati/Library/Localization/Duplicati.Library.Localization.csproj
index c0b7d85de..7e31378b3 100644
--- a/Duplicati/Library/Localization/Duplicati.Library.Localization.csproj
+++ b/Duplicati/Library/Localization/Duplicati.Library.Localization.csproj
@@ -10,4 +10,7 @@
+
+
+
\ No newline at end of file
diff --git a/Duplicati/Library/Localization/LocalizationContext.cs b/Duplicati/Library/Localization/LocalizationContext.cs
index 872fa5250..5eba0d441 100644
--- a/Duplicati/Library/Localization/LocalizationContext.cs
+++ b/Duplicati/Library/Localization/LocalizationContext.cs
@@ -1,4 +1,4 @@
-// Copyright (C) 2024, The Duplicati Team
+// Copyright (C) 2024, The Duplicati Team
// https://duplicati.com, hello@duplicati.com
//
// Permission is hereby granted, free of charge, to any person obtaining a
@@ -19,7 +19,9 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
+using Duplicati.Library.Logging;
using System;
+
namespace Duplicati.Library.Localization
{
///
@@ -43,9 +45,8 @@ namespace Duplicati.Library.Localization
/// The localization to use.
public LocalizationContext(System.Globalization.CultureInfo ci)
{
- m_prev = System.Runtime.Remoting.Messaging.CallContext.LogicalGetData(LocalizationService.LOGICAL_CONTEXT_KEY);
- System.Runtime.Remoting.Messaging.CallContext.LogicalSetData(LocalizationService.LOGICAL_CONTEXT_KEY, ci.Name);
- m_isDisposed = false;
+ m_prev = CallContext.GetData(LocalizationService.LOGICAL_CONTEXT_KEY) as string;
+ CallContext.SetData(LocalizationService.LOGICAL_CONTEXT_KEY, ci.Name); m_isDisposed = false;
}
///
@@ -61,7 +62,7 @@ namespace Duplicati.Library.Localization
{
if (!m_isDisposed)
{
- System.Runtime.Remoting.Messaging.CallContext.LogicalSetData(LocalizationService.LOGICAL_CONTEXT_KEY, m_prev);
+ CallContext.SetData(LocalizationService.LOGICAL_CONTEXT_KEY, m_prev);
m_isDisposed = true;
}
}
diff --git a/Duplicati/Library/Localization/LocalizationService.cs b/Duplicati/Library/Localization/LocalizationService.cs
index 85f2b4499..662f1b712 100644
--- a/Duplicati/Library/Localization/LocalizationService.cs
+++ b/Duplicati/Library/Localization/LocalizationService.cs
@@ -25,6 +25,7 @@ using System.Globalization;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using Duplicati.Library.Localization.Short;
+using Duplicati.Library.Logging;
namespace Duplicati.Library.Localization
{
@@ -97,7 +98,7 @@ namespace Duplicati.Library.Localization
{
get
{
- var lc = System.Runtime.Remoting.Messaging.CallContext.LogicalGetData(LOGICAL_CONTEXT_KEY) as string;
+ var lc = CallContext.GetData(LOGICAL_CONTEXT_KEY) as string;
if (!string.IsNullOrWhiteSpace(lc))
return Get(new CultureInfo(lc));
return Get(CultureInfo.CurrentCulture);
diff --git a/Duplicati/Library/Logging/CallContext.cs b/Duplicati/Library/Logging/CallContext.cs
new file mode 100644
index 000000000..210cbf411
--- /dev/null
+++ b/Duplicati/Library/Logging/CallContext.cs
@@ -0,0 +1,30 @@
+using System.Collections.Concurrent;
+using System.Threading;
+
+namespace Duplicati.Library.Logging
+{
+ ///
+ /// Provides a way to set contextual data that flows with the call and
+ /// async context of a test or invocation.
+ ///
+ public static class CallContext
+ {
+ static ConcurrentDictionary> state = new ConcurrentDictionary>();
+
+ ///
+ /// Stores a given object and associates it with the specified name.
+ ///
+ /// The name with which to associate the new item in the call context.
+ /// The object to store in the call context.
+ public static void SetData(string name, object data) =>
+ state.GetOrAdd(name, _ => new AsyncLocal