System.ObjectDisposedException: Cannot access a closed Stream when running this statement MemoryStream stream = (MemoryStream)data.GetData(cbExpression, false)

HARISH VN 1 Reputation point
2021-07-27T07:47:11.967+00:00

public ResolvedExpression GetClipBoardExpression()
{
try
{

            IDataObject data = Clipboard.GetDataObject();
            if (!data.GetDataPresent(cbExpression, false))
                return null;

            using (MemoryStream stream = (MemoryStream)data.GetData(cbExpression, false))   `**>>>>>> Exception comes here , And this happens when copy and pasting text using ctrl+c and ctrl+v  and only using RealVNC veiwer.**

            {
                    BinaryReader reader = new BinaryReader(stream, System.Text.Encoding.UTF8);
      }
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,018 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.