Hello there,
Runspaces.RunspaceFactory.CreateRunspace() For this case the solution was to edit the project file and make sure the reference to related asembly looks exactly so:
<Reference Include="System.Management.Automation" />
Similar discussion here https://social.msdn.microsoft.com/Forums/office/en-US/6d8fd57d-6d44-4b8e-a9e1-8b5b5ad17aab/runspacefactorycreaterunspace-causes-clr-error?forum=msbuild
Hope this resolves your Query !!
--If the reply is helpful, please Upvote and Accept it as an answer--