Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Problems using Microsoft.Data.SqlClient in custom c# Powershell CmdLet #2077

DevOma75 started this conversation in General
Discussion options

I run into a version conflict when trying to write my own CmdLet in c# (.NET Framework 4.7.2) using Microsoft.Data.SqlCLient - just these few lines of code are always resulting in some errors because SqlClient wants to load System.Memory version 4.0.1.1 - I need this dll for other nuget packages and have updated to latest version - I found no solution how to prevent SqlClient to use the old version of System.Memory

using Microsoft.Data.SqlClient;
using System;
using System.Management.Automation;
namespace CmdLetTest
{
 public class CmdLetEnvironment
 {
 public static bool Connected = false;
 [System.Management.Automation.Cmdlet(System.Management.Automation.VerbsCommunications.Connect, "RDTest")]
 public class RDEnvironmentConnectCommand : System.Management.Automation.PSCmdlet
 {
 protected override void ProcessRecord()
 {
 try
 {
 SqlConnection conn = new SqlConnection("Data Source=localhost\\SQLEXPRESS;Initial Catalog=Test;Integrated Security=True;Encrypt=False");
 conn.Open();
 }
 catch(Exception ex)
 {
 throw ex.InnerException;
 }
 }
 }
 }
}

Error is always
Could not load file or assembly 'System.Memory, Version=4.0.1.1, Culture=neutral,
PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.

Any help on this issue??? Have tried so many different things (like app.config settings) but nothing seems to work

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /