Repository navigation
Open
Description
I've searched this repository along with the sqlclient repository. There are multiple issues bring this up but are either closed or solutions provided don't seem to fix the issue I'm getting.
I'm trying to create a basic binary module in PowerShell against SQL Server. I have a basic project structure with just one cmdlet so far (trying to see if this even works) that references SMO library.
The project compiles for dotnet 6 on my M1 and the module imports with no issues. It is not until I call the Connect-DblServer:
Exception :
Type : System.PlatformNotSupportedException
TargetSite : Void .ctor()
Message : Microsoft.Data.SqlClient is not supported on this platform.
Source : Microsoft.Data.SqlClient
HResult : -2146233031
StackTrace :
at Microsoft.Data.SqlClient.SqlConnection..ctor()
at Microsoft.SqlServer.Management.Common.ConnectionManager..ctor(IRenewableToken token, Boolean removeIntegratedSecurity)
at Microsoft.SqlServer.Management.Common.ConnectionManager..ctor()
at Microsoft.SqlServer.Management.Common.ServerConnection..ctor()
at dbalight.cmdlets.general.ConnectServerCmdlet.ProcessRecord() in
/Users/smelton/git/dbalight/source/dbalight/cmdlets/public/ConnectServer.cs:line 41
at System.Management.Automation.Cmdlet.DoProcessRecord()
at System.Management.Automation.CommandProcessor.ProcessRecord()
CategoryInfo : NotSpecified: (:) [Connect-DblServer], PlatformNotSupportedException
FullyQualifiedErrorId : System.PlatformNotSupportedException,dbalight.cmdlets.general.ConnectServerCmdlet
InvocationInfo :
MyCommand : Connect-DblDblServer
ScriptLineNumber : 1
OffsetInLine : 1
HistoryId : 26
Line : Connect-DblServer -ServerInstance 'localhost,1432' -Verbose
PositionMessage : At line:1 char:1
+ Connect-DblServer -ServerInstance 'localhost,1432' -Verbose
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
InvocationName : Connect-DblServer
CommandOrigin : Internal
ScriptStackTrace : at <ScriptBlock>, <No file>: line 1Line 41 of that cs file for the cmdlet is: ServerConnection srvCn = new ServerConnection();
- Is there something in my csproj that I have configured wrong?
- Is this just broken and I need to revert to an older version of the SQLManagementObjects library?
Metadata
Metadata
Assignees
Labels
No labels
Activity
shueybubbles commentedon Oct 10, 2023
is your deployment somehow copying the
Microsoft.Data.SqlClient.dllfile fromlibinstead of fromruntimes?DavoudEshtehari commentedon Oct 11, 2023
I tried to compile and use the sample project on ARM supported machine and I got the platform not supported exception on PS7. Then I tried locally on Windows 11 and x64, which didn't change the result. Can you share the commands and instructions if you could run it on a x64 supported machine and it's only an ARM related issue?

wsmelton commentedon Oct 11, 2023
DavoudEshtehari run the above in PowerShell 7.2+ should get it going.
I don't have access to any Windows device, only on a Apple Mac M1:
David Shiflet (@shueybubbles) on the build process I'm only running
dotnet build -c Releaseso it creates inbin/net6.0/osx.12-arm64. The module build I'm copying that path up to the module's directory (minus the osx folder reference).DavoudEshtehari commentedon Oct 11, 2023
Seems it requires some more configurations! I followed the above instruction on the ARM machine.
wsmelton commentedon Oct 11, 2023
I don't have Windows nor do I use it so unsure what additional requirements there would be to get the build of the project to run successful.
wsmelton commentedon Oct 14, 2023
DavoudEshtehari that error comes from two things:
dotnet-gitversioninstalled on your machinegitversionto be used (it requires the git database for the project to be on your local device)wsmelton commentedon Oct 15, 2023
If I use either SMO for
netstandard2.0ornet6.0neither one seems to work on Mac.I have 6 and 7 SDK installed on the device:
DavoudEshtehari commentedon Oct 16, 2023
Shawn Melton (@wsmelton) Thanks,
dotnet-gitversionwas required and I confirm the build ran successfully either on x64 or ARM64 Win 11 machines, but the result is identical after running the following commands:Connect-Server: Microsoft.Data.SqlClient is not supported on this platform.shueybubbles commentedon Mar 8, 2024
DavoudEshtehari should this issue move over to dotnet/sqlclient?
DavoudEshtehari commentedon Mar 8, 2024
I don't have permission to move it into SqlClient. I'd appreciate it if you could do it.
shueybubbles commentedon Mar 8, 2024
you'd have to open a new one then we can close this one with a link to it. Moving issues only works within the same organization.