title: How to serialize a Dictionary<object, guid>?
body: <p>I'm currently building an application where I have some tasks that are sharing a Dictionary&lt;Object, Guid&gt;.</p>
  <p>To avoid conflicts, the actual Dictionaries are contained within a DictionaryHandler-class with three methods:</p>
  <pre><code>class DictionaryHandler
  {
      
      private object lockProcesses = new object();
      private Dictionary&lt;Process, Guid&gt; processes = new Dictionary&lt;Process, Guid&gt;();
  
      public Dictionary&lt;Process, Guid&gt; GetProcesses()
      {
          lock (lockProcesses)
          {
              // TODO
          }   
      }
  
      public void AddToProcesses(Process process, Guid guid)
      {
          lock (lockProcesses)
          {
              processes.Add(process, guid);
          }
      }
  
      public void RemoveFromProcesses(Process process)
      {
          lock (lockProcesses)
          {
              processes.Remove(process);
          }
      }
  }
  </code></pre>
  <p>For context, this is the Process-class:</p>
  <pre><code>public class Process
  {
      public string Name { get; }
      public bool Enabled { get; }
      public TimeSpan RuntimeWindowStart { get; }
      public TimeSpan RuntimeWindowEnd { get; }
      public TimeSpan Cooldown { get; }
      public int Priority { get; }
      public string Username { get; }
      public string ExceptionDate { get; }
      public string ExceptionDay { get; }
      public string AllowedWorkdays { get; }
      public string SpecificResource { get; }
      public string Assigned { get; set; }
      public DateTime? Timestamp { get; set; }
  
      public Process(string name, bool enabled, TimeSpan runtimeWindowStart, TimeSpan runtimeWindowEnd, TimeSpan cooldown, int priority, string username, string exceptionDate, string exceptionDay, string allowedWorkdays, string specificResource, string assigned, DateTime? timestamp)
      {
          Name = name;
          Enabled = enabled;
          RuntimeWindowStart = runtimeWindowStart;
          RuntimeWindowEnd = runtimeWindowEnd;
          Cooldown = cooldown;
          Priority = priority;
          Username = username;
          ExceptionDate = exceptionDate;
          ExceptionDay = exceptionDay;
          AllowedWorkdays = allowedWorkdays;
          SpecificResource = specificResource;
          Assigned = assigned;
          Timestamp = timestamp;
      }
  }
  </code></pre>
  <p>My main issue is that I want to find a way to return a copy of the Dictionary through the GetProcesses()-method, without returning a reference to the &quot;actual&quot; dictionary.</p>
  <p>As far as I can see, the optimal way to do this is to Serialize and Deserialize the Dictionary and return that. But I'm having a hard time doing this, as I'm unable to find an example that matches my case.</p>
  <p>I've read <a href="https://www.newtonsoft.com/json/help/html/SerializeDictionary.htm" rel="nofollow noreferrer">this</a> and <a href="https://www.newtonsoft.com/json/help/html/SerializeObject.htm" rel="nofollow noreferrer">this</a> and tried to combine the two - unfortunately without luck.</p>