C# sample server, problems. Please Help


http://www.s-code.com/forum/Topic2149.aspx
Print Topic | Close Window

By namwenio - Thursday, July 31, 2008
This method cannot be used while the control running in the "design-time" mode.

I get this error every time I try to execute this code.

I need to be able to use the API, without adding it to a form.
The reason for this is because it will be run as a service on client machines.

How would I perform this funcionality?

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace vnctester

{
       
public partial class Form1 : Form
       
{
            ServerX.
CSC_ServerXControl XServer = new ServerX.CSC_ServerXControl();

        public Form1()
       
{
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            XServer.AddClientEx(
"an ip address", 5500, "ID:1234");
        }
    }
}

By Yury Averkiev (s-code) - Thursday, July 31, 2008
Hi,
have you tried to create a hidden Form with ServerX placed on it?
By namwenio - Tuesday, August 05, 2008
Yes,

Here is the problem I run into.

My program is not forum oriented it's component driven and multi threaded.
When I do add a hidden forum I get this error.

ActiveX control '8818cf4d-2190-49c3-b7eb-b9f2ae198cb1' cannot be instantiated because the current thread is not in a single-threaded apartment.

It will not allow me to add the activeX object to a component.

Is their a way to run this in a multi-threaded application?

By Yury Averkiev (s-code) - Tuesday, August 05, 2008
Are you getting this error while adding the ActiveX to a .Net or native Win32 based application.

Also, you don't use the ActiveX inside a SingleClick package, do you? If you do, please note that there is a bug in the Microsoft's manifest file generator; it's spells the appointment value incorrectly.
By deX - Thursday, August 28, 2008
If you use the COM wrappers for .NET in the sample code everything works great.