nvnc instance in vbnet

Apr 22, 2013 at 12:14 PM
hello, I'm using your nvnc.dll in a vbnet project, inside a thread.
works ok, except the colors is very low quality.
if I use your exe compilation, works ok, but using your dll inside thread, the colors looks very low quality (seems as 8 bit color).
any idea? thanks in advance
Apr 22, 2013 at 12:34 PM
here's my code, just to help in debug process:

Public t2 As Thread
If (IsPortOpen("localhost", "5900")) = False Then
 'port is closed, must open it
 t2 = New Thread(AddressOf Me.IniciarVNC)
 t2.IsBackground = True
 t2.Priority = ThreadPriority.Highest
 t2.Start()
End If
Apr 22, 2013 at 11:43 PM
@crosemffet:
Can you please also post the code of Me.IniciarVNC ?
Also, try running the code outside of a thread.
Apr 23, 2013 at 10:55 AM
Edited Apr 23, 2013 at 10:57 AM
@t1t4n, thanks for your reply. you are veri kind.
I've been making some test about it, according to your suggestions.
outside threads, running as stand alone, the server works ok, but inside the thread the color still low quality.
IniciarVNC code:

Public Sub IniciarVNC()
    Try
        Dim myVnc As New NVNC.VncServer
        myVnc.Name = "crosemffet"
        myVnc.Password = "1234"
        myVnc.Port = "5900"
        myVnc.Start()

    Catch ex As Exception
        System.Diagnostics.Debug.WriteLine(ex.Message)
        System.Threading.Thread.Sleep(1000)
    End Try
End Sub

another problem: even working fine, the server takes a very long time to update the screen. is not very responsive. i've been trying to investigate the code, and try a small changes, according to your suggestions about to update smaller parts of the screen in pieces
the vbnet ask me for password from nvnc.pfx in order tu open the project.
can you point me in the right direction about it?
thanks again for your support.
Apr 23, 2013 at 6:25 PM
Hello,
I have tried to use NVNC in a VB.NET test app, and it works correctly.
The code I used is this:
Imports System
Imports System.Threading
Imports NVNC
Module Module1
    Public Sub IniciarVNC()
        Try
            Dim myVnc As New NVNC.VncServer
            myVnc.Name = "crosemffet"
            myVnc.Password = "1234"
            myVnc.Port = "5900"
            myVnc.Start()

        Catch ex As Exception
            System.Diagnostics.Debug.WriteLine(ex.Message)
            System.Threading.Thread.Sleep(1000)
        End Try
    End Sub
    Sub Main()
        Dim t2 As Thread
        'port is closed, must open it
        t2 = New Thread(AddressOf IniciarVNC)
        t2.IsBackground = True
        t2.Priority = ThreadPriority.Highest
        t2.Start()
        Console.ReadLine()
    End Sub
End Module
About the issue with the NVNC.pfx, that is the strong-name key file. Try deleting it, and de-check signing in project settings, then try recompiling the code.
If you are using the source in your project, the colours issue might be due to some bad color settings on the viewer (you might post a screenshot of the viewer settings), or because wrong parameters I had put in the constructor of VncServer.
You should change it as following:
public VncServer()
{
       Size screenSize = ScreenSize();
        fb = new Framebuffer(screenSize.Width, screenSize.Height);

        fb.BitsPerPixel = 32;
        fb.Depth = 24;
        //fb.BigEndian = true;
        fb.TrueColour = true;
        fb.RedShift = 16;
        fb.GreenShift = 8;
        fb.BlueShift = 0;
        fb.RedMax = fb.GreenMax = fb.BlueMax = 0xFF;
}

public VncServer(string password, int port, string name)
{
        Size screenSize = ScreenSize();
        fb = new Framebuffer(screenSize.Width, screenSize.Height);

        fb.BitsPerPixel = 32;
        fb.Depth = 24;
        //fb.BigEndian = true;
        fb.TrueColour = true;
        fb.RedShift = 16;
        fb.GreenShift = 8;
        fb.BlueShift = 0;
        fb.RedMax = fb.GreenMax = fb.BlueMax = 0xFF;

        this.Password = password;
        this.Port = port;
        this.Name = name;
}
If, on the other hand, you are using NVNC as a binary file (.dll), then you can wait until my next release of the code, which hopefully will support compression.
I should release it sometime soon.

Thanks for using NVNC and please rate, share, comment and report bugs,
T1T4N
Apr 24, 2013 at 9:40 AM
I’ve been making some tests, and you are right about the color destruction. The problem is not the server, is the client.
I’m using TightVNC java viewer 2.6. the parameters for connection are:
        <param name="Host" value="myLocalIP" />
        <param name="Port" value="5900" />
        <param name="Password" value="1234" />
        <param name="OpenNewWindow" value="yes" />
        <param name="ShowControls" value="no" />
        <param name="ViewOnly" value="yes" />
        <param name="AllowClipboardTransfer" value="no" />
                    <param name="RemoteCharset" value="standard" />
        <param name="ShareDesktop" value="yes" />
        <param name="AllowCopyRect" value="yes" />
        <param name="Encoding" value="Raw" />
        <param name="CompressionLevel" value="" />
        <param name="JpegImageQuality" value="6" />
        <param name="LocalPointer" value="On" />
        <param name="ConvertToASCII" value="no" />
        <param name="colorDepth" value="32" />
        <param name="ScalingFactor" value="100" />
                    <param name="sshHost" value="" />
                 <param name="sshUser" value="" />
     <param name="sshPort" value="" />
I think could be a compression problem. Do you have any better http client to recommend me? (Java or javascript, but need to be browser based, or any parameter modification that could work?
Removing the .pfx file, compilation goes fine, but the slow refreshing problem continues. Sometimes takes up to 5 seconds to get the new frame from server. There’s any chance in the next days to get the new version from you ?
Thanks again from your support,
Marked as answer by T1T4N on 3/4/2014 at 12:50 PM
Oct 11, 2014 at 3:53 PM
Hi to all,
I insert this feature on my VB.NET application and all is OK before I try to close thred. I need also to redirect output on a multiline test field.

If I try to di this, vb,net, told me that the object is not set. Can anyone help me?
I attach below the code:
'
' Created by SharpDevelop.
' User: rbianchi
' Date: 11/10/2014
' Time: 15:31
' 
' To change this template use Tools | Options | Coding | Edit Standard Headers.
'
Imports Microsoft.Win32
Imports System 
Imports System.IO 
Imports System.Management
Imports System.Windows.Forms
Imports System.Drawing.Icon
Imports Microsoft.VisualBasic.Interaction
Imports System.Reflection
Imports System.Net
Imports NVNC
Imports System.Threading
Imports System.Net.Sockets

Public Partial Class vncconsole
    Private t2 As Thread
    Private myVnc As New NVNC.VncServer
    Public Sub New()
        ' The Me.InitializeComponent call is required for Windows Forms designer support.
        Me.InitializeComponent()
        
        '
        ' TODO : Add constructor code after InitializeComponents
        '
        'Dim t2 As Thread
        t2 = New Thread(AddressOf Me.vnc_start)
        MsgBox(t2.ManagedThreadId.ToString)
        t2.Name = "psysvnc"
        t2.IsBackground = True
        t2.Priority = ThreadPriority.Highest
        t2.Start()
    End Sub
    
    
    
    sub vnc_start       
        Try
        
        myVnc.Name = "psys_support"
        myVnc.Password = "pre14sys"
        myVnc.Port = "5900"
        myVnc.Start()
  
                        
    Catch ex As Exception
        'System.Diagnostics.Debug.WriteLine(ex.Message)
       ' System.Threading.Thread.Sleep(1000)
    End Try
    End Sub
    
    Sub RacClick(sender As Object, e As EventArgs)
        Try
            myVnc.Stop()
            t2.Abort()
        Catch ex As Exception
            MsgBox (ex.Message) 
        end try     
        Me.Close
    End Sub
End Class
Thanks to all
Biroby