I'm new to PowerShell. I'm trying to call a method of my custom C# dll. I failed due to multiple reasons.
Here is my code:
[System.Reflection.assembly]::LoadFile("E:\Mulukutla\Migration.dll")
$MyClass = New-Object DataMigration
$MyClass.MigrateData("$from\$name","$to\$name")
C# class library I used is build in 4.0 and powershell v2.0
Exception calling "LoadFile" with "1" argument(s): "This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded. (Exception from HRESULT: 0x8013101B)" At E:\Mulukutla\myCodev1.ps1:3 char:39 + [System.Reflection.assembly]::LoadFile <<<< ("E:\Mulukutla\Migration.dll") + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : DotNetMethodException
New-Object : Cannot find type [DataMigration]: make sure the assembly containing this type is loaded. At E:\mulukutla\myCodev1.ps1:4 char:21 + $MyClass= New-Object <<<< DataMigration + CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException
+ FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand
Please help me by correcting, what is the mistake I'm doing?