InvalidOperationException when processor affinity is being set.

Narendra V 1 Reputation point
2022-04-29T13:46:58.937+00:00

After creation of the process as shown below . I am getting the following exception "System.InvalidOperationException: 'No process is associated with this object.'". Please let me know
how to resolve this exception.

Process cmdline = new Process();
cmdline.ProcessorAffinity = (IntPtr)0x0001;

Developer technologies C#
{count} votes

2 answers

Sort by: Most helpful
  1. Castorix31 90,521 Reputation points
    2022-04-29T13:57:10.437+00:00

    You must start the process first.
    Like in the MS sample for threads : ProcessThread.ProcessorAffinity


  2. Narendra V 1 Reputation point
    2022-05-01T02:38:34.433+00:00

    Can you please explain what is normal here and why exception is being thrown?

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.