Powershell 5.1.x, Windows 10 Pro.
When running the following command in the default PowerShell console:
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Management.SqlParser")
it runs OK and I can use the SqlParser classes and methods subsequently.
However, the same command executed in Visual Studio Code debug session results in:
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlS …
Exception calling "LoadWithPartialName" with "1" argument(s): "Could not load file or assembly
'Microsoft.SqlServer.Management.SqlParser, Culture=neutral, PublicKeyToken=null'. Operation is not supported. (0x80131515)"
VSC runs with the same privileges as the standard PS console. What am I doing wrong? How to successfully load the assembly in VSC?
Update: the following code works fine in VSC:
[System.Reflection.Assembly]::LoadFrom("C:\WINDOWS\assembly\GAC_MSIL\Microsoft.SqlServer.Management.SqlParser\11.0.0.0__89845dcd8080cc91\Microsoft.SqlServer.Management.SqlParser.dll")
so I am not blocked anymore. Still, the question remains: why does the ::LoadWithPartialName
method work in one place but not the other?
User contributions licensed under CC BY-SA 3.0