locked
is it possible to get "Console.WriteLine"(of a library) form a windows form application RRS feed

  • Question

  • hi

       i'd like to ask a question.

       I have a dll file, in this dll file, there is a code of Console.WriteLine

       Then there is a windows form application call this code of this dll

       My question is, is it possible i can find the content of Console.WriteLine? 

       My situation is, the application is already installed on the customer's PC. i cannot dubug it

       thank you very much

    best regards

    
    
    Friday, July 3, 2015 12:34 PM

Answers

  • Hello,

    The following demo uses a Class project and a forms project.

    Class project (add a reference for windows forms). 

    Imports System.IO
    Imports System.Text
    Imports System.Windows.Forms
    Public Class TextBoxStreamWriter
        Inherits TextWriter
        Private outPut As TextBox = Nothing
        Public Sub New(ByVal output As TextBox)
            outPut = output
        End Sub
        Public Overrides Sub Write(ByVal value As Char)
            MyBase.Write(value)
            outPut.AppendText(value.ToString()) ' append it to the text box.
        End Sub
        Public Overrides ReadOnly Property Encoding() As Encoding
            Get
                Return System.Text.Encoding.UTF8
            End Get
        End Property
    End Class
    Public Class Demo
        Private _writer As TextWriter = Nothing
        Public Sub New(ByVal sender As TextBox)
            _writer = New TextBoxStreamWriter(sender)
            Console.SetOut(_writer)
        End Sub
        Public Sub Talk(ByVal sender As String)
            Console.WriteLine(sender)
        End Sub
        Public Sub Talk()
            Console.WriteLine(Now.Year)
        End Sub
    End Class
    

    Form1 in the forms project, two buttons and two textbox controls

    Public Class Form1
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Dim talker As New Demo(TextBox1)
            TextBox1.Text = ""
            talker.Talk("Greetings")
        End Sub
        Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
            Dim talker As New Demo(TextBox1)
            TextBox1.Text = ""
            talker.Talk()
        End Sub
    End Class
    
    The first button allows you to specify text while the second uses pre-defined text. Hope this helps.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my webpage under my profile but do not reply to forum questions.

    Friday, July 3, 2015 12:57 PM
  • hi

       thank u very much for your reply and sorry for my late reply

       If the app is already installed on a customers PC then does that mean you don't want to alter the app in order to do anything to it?

         i dont want to alter the app.

        You say you want to get information from your app when your app calls a .Dll which has a Console.WriteLine method in the .Dll? Is that correct? And also you can't alter that app?

            exactly

       it's not remote debugging.

        now it seems that i understand, if the windows application is already installed on user's PC with a dll liberay. i dont know why the programmer who wrote that dll wrote the code of console.writeline. so i was thinking for windows application, if the console.writeline is executed, maybe in some place we can found it. but it seems that it is impossible,right?

        thank u very much again

    I'm not certain since I've never used a .Dll that calls the Console.WriteLine method. I suspect the app would require a Console app for something to display.

    Regardless it's possible that an external app like API Monitor, which I've never used and is free, may be able to monitor the .Dll you mention for incoming and outgoing information from that .Dll but I'm not certain. API Monitor requires custom definitions for monitoring custom .Dlls also. But it can monitor threads too apparently.


    La vida loca

    Thursday, July 9, 2015 9:53 AM

All replies

  • Hello,

    The following demo uses a Class project and a forms project.

    Class project (add a reference for windows forms). 

    Imports System.IO
    Imports System.Text
    Imports System.Windows.Forms
    Public Class TextBoxStreamWriter
        Inherits TextWriter
        Private outPut As TextBox = Nothing
        Public Sub New(ByVal output As TextBox)
            outPut = output
        End Sub
        Public Overrides Sub Write(ByVal value As Char)
            MyBase.Write(value)
            outPut.AppendText(value.ToString()) ' append it to the text box.
        End Sub
        Public Overrides ReadOnly Property Encoding() As Encoding
            Get
                Return System.Text.Encoding.UTF8
            End Get
        End Property
    End Class
    Public Class Demo
        Private _writer As TextWriter = Nothing
        Public Sub New(ByVal sender As TextBox)
            _writer = New TextBoxStreamWriter(sender)
            Console.SetOut(_writer)
        End Sub
        Public Sub Talk(ByVal sender As String)
            Console.WriteLine(sender)
        End Sub
        Public Sub Talk()
            Console.WriteLine(Now.Year)
        End Sub
    End Class
    

    Form1 in the forms project, two buttons and two textbox controls

    Public Class Form1
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Dim talker As New Demo(TextBox1)
            TextBox1.Text = ""
            talker.Talk("Greetings")
        End Sub
        Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
            Dim talker As New Demo(TextBox1)
            TextBox1.Text = ""
            talker.Talk()
        End Sub
    End Class
    
    The first button allows you to specify text while the second uses pre-defined text. Hope this helps.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my webpage under my profile but do not reply to forum questions.

    Friday, July 3, 2015 12:57 PM
  • I don't get what you mean.

    If the app is already installed on a customers PC then does that mean you don't want to alter the app in order to do anything to it?

    You say you want to get information from your app when your app calls a .Dll which has a Console.WriteLine method in the .Dll? Is that correct? And also you can't alter that app?

    Please specify exactly what you are wanting to do. Because it sounds to me the only way to do what you want is via remote debugging unless some other app available somewhere can monitor your process somehow and provide info on each line in the app being called perhaps. I guess that remote debugging could monitor execution of code in an app but don't really know.

    Remote Debugging and Diagnostics

    How to: Set Up Remote Debugging


    La vida loca

    Friday, July 3, 2015 2:28 PM
  • thank u very much
    Thursday, July 9, 2015 9:28 AM
  • hi

       thank u very much for your reply and sorry for my late reply

       If the app is already installed on a customers PC then does that mean you don't want to alter the app in order to do anything to it?

         i dont want to alter the app.

        You say you want to get information from your app when your app calls a .Dll which has a Console.WriteLine method in the .Dll? Is that correct? And also you can't alter that app?

            exactly

       it's not remote debugging.

        now it seems that i understand, if the windows application is already installed on user's PC with a dll liberay. i dont know why the programmer who wrote that dll wrote the code of console.writeline. so i was thinking for windows application, if the console.writeline is executed, maybe in some place we can found it. but it seems that it is impossible,right?

        thank u very much again

    Thursday, July 9, 2015 9:39 AM
  • hi

       thank u very much for your reply and sorry for my late reply

       If the app is already installed on a customers PC then does that mean you don't want to alter the app in order to do anything to it?

         i dont want to alter the app.

        You say you want to get information from your app when your app calls a .Dll which has a Console.WriteLine method in the .Dll? Is that correct? And also you can't alter that app?

            exactly

       it's not remote debugging.

        now it seems that i understand, if the windows application is already installed on user's PC with a dll liberay. i dont know why the programmer who wrote that dll wrote the code of console.writeline. so i was thinking for windows application, if the console.writeline is executed, maybe in some place we can found it. but it seems that it is impossible,right?

        thank u very much again

    I'm not certain since I've never used a .Dll that calls the Console.WriteLine method. I suspect the app would require a Console app for something to display.

    Regardless it's possible that an external app like API Monitor, which I've never used and is free, may be able to monitor the .Dll you mention for incoming and outgoing information from that .Dll but I'm not certain. API Monitor requires custom definitions for monitoring custom .Dlls also. But it can monitor threads too apparently.


    La vida loca

    Thursday, July 9, 2015 9:53 AM
  • ok, thank u very much

    i will try API monitor

    best regards

    martin

    Thursday, July 9, 2015 10:15 AM