I am trying to write a PS script that will open a stored proc, pass parameters and execute that proc, then output the data to a DataSet. That all seems to work, but whern I try to create a .NET object inside an Add-Type block, I get the error:
The type or namespace ‘Data’ does not exist in the namespace ‘System’
(are you missing an assembly reference?)
Here’s the code:
Add-Type @'
using System.Data;
using System.Collections.Generic;
public class TestObject
{...}
'@
The part that’s really confusing me is that I create a DataSet in another part of the code, outside of the .NET class, and the reference to System.Data.DataSet works fine.
Any thoughts on this are greatly appreciated.
You need to add System.Data to the
-ReferencedAssembliesparameter ofAdd-Type