C# and -Path

I have an issue when trying to load an assembly -Path is coming back as Null. Not sure why but here is my code snippet

Add-Type -Path "C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.XML.dll"
$assemblies=@(
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.XML.dll"
)
Add-Type $code = @'
using System;
using System.Xml;
using system.Text;

public class testItem
{
     public static string searchMachine()
      {
        return "TEST";
      }
'@
Add-Type -ReferencedAssemblies $assemblies -TypeDefinition $code -Language CSharpVersion3
[testItem]::searchMachine()

try this:

$Source = @"
using System;
using System.Xml;
    public class PS
    {
      public static string searchMachine()
      {
        return "TEST";
      }
    }
"@

$referencingassemblies = ("C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.XML.dll")
Add-Type  -TypeDefinition $Source -ReferencedAssemblies $referencingassemblies -Language CSharp
[PS]::searchMachine()

Tried that Rick. Did not work. keeps saying same error Path is null.

I did a test-path and it came back true. Not sure why its still erroring

GOT IT…noticed I had ADD TYPE for the code part. So instead of ADD-TYPE $code = @" I only need $code = @"