title: PowerShell Add-Type : Cannot add type. already exist
body: <p>I'm using PowerShell script to run C# code directly in the script. I've run in to an error a particular error a few times. If I make any changes to the C# code in the PowerShell ISE and try to run it again I get the following error.</p>
  
  <pre><code>Add-Type : Cannot add type. The type name 'AlertsOnOff10.onOff' already exists.
  At C:\Users\testUser\Desktop\test.ps1:80 char:1
  + Add-Type -TypeDefinition $Source -ReferencedAssemblies $Assem
  + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : InvalidOperation: (AlertsOnOff10.onOff:String) [Add-Type], Exception
      + FullyQualifiedErrorId : TYPE_ALREADY_EXISTS,Microsoft.PowerShell.Commands.AddTypeCommand
  </code></pre>
  
  <p>The way I have been resolving this error is by changing the namespace and the command to call the C# method <code>[AlertsOnOff10.onOff]::Main("off")</code>. I there a way I can prevent this error from happening without having to change namespace and method call?</p>