Why doesn't Powershell recognize System.Data inside the Add_Type block?

I am trying to write a PS script that will open the stored parameters proc, pass and execute this proc, and then output the data to a DataSet. This seems to work, but I'm trying to create a .NET object inside an Add-Type block, I get an error:

The type or namespace "Data" does not exist in the namespace "System", (do you miss the assembly reference?)

Here is the code:

Add-Type @' using System.Data; using System.Collections.Generic; public class TestObject {...} '@ 

The part that really confuses me is that I create a DataSet in another part of the code outside of the .NET class, and the link to System.Data.DataSet works fine.

Any thoughts on this are greatly appreciated.

+4
source share
1 answer

You need to add System.Data to the -ReferencedAssemblies Add-Type parameter

+3
source

Source: https://habr.com/ru/post/1411994/


All Articles