|
System.InvalidOperationException
Чесноков
|
|
|
|
|
1) You need to ensure the custom command code is between 128 and 256.Values below 128 correspond to system-reserved values and values up 256 are restricted.
2) It seems that there's no standart framework designed to send and receive data to windows service and back.It's only a few information on the internet for this problem but I believe that it shouldn't be difficult to implement communication with a service based on sockets or named pipes.
[EDIT]
You could also set AutoLog property of ServiceBase class to true to gather information about custom commands execution from the eventlog.
Life is a stage and we are all actors!
modified on Tuesday, October 27, 2009 7:07 AM
|
|
|
|
|
1) They were starting from 0 actually (0,1,2, ...)
2) I needed custom commands to get the feedback from the service, the same as you call ordinary function and it returns some error code. Otherwise I will have to implement such other communication
Looking into logs would sute only for visual inspection.
Чесноков
|
|
|
|
|
As it's mentioned in the documentation here custom command codes should be only between 128 and 256:
The only values for a custom command that you can define in your application or use in OnCustomCommand are those between 128 and 256. Integers below 128 correspond to system-reserved values.
Just take a look to this sample that demonstrates this behavior.
I haven't found almost nothing about sending and receiving that from service but after analyzing some service based apps like SQL Server Db engine I suppose they it uses TCP socket on port 1433 and named pipes to serve the clients.
Life is a stage and we are all actors!
|
|
|
|
|
how to send the message sent from one client to another client, plz help me.
|
|
|
|
|
By writing code. Perhaps you need to ask something more specific ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
there are 2 systems with ips 192.168.1.87(clientA,serverA) and 192.168.1.35(clientB,serverB) . on both the systems client and server runs.
now clientA sends a message to serverB on button click. as soon as serverB recieves a message it should send that message to ClientB
how is that possible
clientA--->serverB(onmessagerecieved)--->cientB
server:-
int recv;
byte[] data = new byte[1024];
IPEndPoint ipep = new IPEndPoint(IPAddress.Any, 10294);
Socket newsock = new Socket(AddressFamily.InterNetwork,
SocketType.Dgram, ProtocolType.Udp);
newsock.Bind(ipep);
newsock.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(IPAddress.Any, IPAddress.Parse("127.0.0.1")));
while (true)
{
IPEndPoint sender2 = new IPEndPoint(IPAddress.Any, 0);
IPEndPoint sender1 = new IPEndPoint(IPAddress.Parse("192.168.1.35") , 0);
EndPoint tmpRemote = (EndPoint)(sender2);
EndPoint tmpRemote1 = (EndPoint)(sender1);
data = new byte[1024];
recv = newsock.ReceiveFrom(data, ref tmpRemote);
Console.WriteLine(Encoding.ASCII.GetString(data, 0, recv));
string welcome = "7010";
data = Encoding.ASCII.GetBytes(welcome);
newsock.SendTo(data, data.Length, SocketFlags.None, tmpRemote1 );
}
client:-
IPEndPoint ipep = new IPEndPoint(IPAddress.Parse("192.168.1.35"), 10294);
byte[] data = new byte[1024];
Socket client = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
private void Form1_Load(object sender, EventArgs e)
{
client.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, 10);
}
private void button1_Click(object sender, EventArgs e)
{
string welcome = "What's your IP?";
data = Encoding.ASCII.GetBytes(welcome);
client.SendTo(data, data.Length, SocketFlags.None, ipep);
}
private void timer1_Tick(object sender, EventArgs e)
{
IPEndPoint server = new IPEndPoint(IPAddress.Any, 0);
EndPoint tmpRemote = (EndPoint)server;
data = new byte[1024];
int recv = client.ReceiveFrom(data, ref tmpRemote);
this.richTextBox1.Text = Encoding.ASCII.GetString(data, 0, recv);
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
client.Close();
}
|
|
|
|
|
Try creating a TcpListener , listening at a local endpoint and accepting tcp connections
TcpListener listener = new TcpListener(YOUR EndPoint here(new LocalEndPoint(....)));
listener.Start();
Listener.AcceptTcpConnections...
//Wait for new Connection from Client
Then at the Client Side you should simply create a TcpClient and connect To a RemoteEndPoint which is what u've created as localEndpoint at your server side,
TcpClient tcpc = new TcpClient(remoteEndPoint);
then you can send objects to server and obtain responses
try http://www.google.com/search?hl=en&source=hp&q=simple+Client+Server+C%23&aq=f&oq=&aqi=
|
|
|
|
|
Want Remote Connection in Sql Server with C# application ... via Sql Server Authentication... Data Souurce name was created Successfully ... But Could not Access that DataSource name from our C# appliction...Wht is Trusted in Sql Server ....
Thanks
|
|
|
|
|
So did you look at what I suggested when you posted this in the VB forum?
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
|
Hi,
In my application I am using first, next, previous buttons for displaying images. I will select images belonging to particular category and place them in a dataset. From here I have to select first 6 images when I click first button, next 6 images when I click next button like that.
So when I click next, I have select the images after the 6th image Id from the data set.
If anyone have any idea to do this please reply me.
Thanks in advance.
|
|
|
|
|
dataSet.Tables[tableNumber].Rows[rowNumber][columnNumber], surely?
Cheers,
Vikram. (Cracked not one CCC, but two!)
|
|
|
|
|
|
Hi All,
I Created one Class Library(Dynamic Link Library) in C#. I want to use this dll in another C# Windows Application. I do not want to use this through Add Reference option, I want to use or Load this dll in runtime. Please give me some solution to this problem.Give me some hints to solve this problem.
Thanks & Regards,
Savitri P
|
|
|
|
|
Hello
We have a C# windows application with around 400-450 forms. Now we sell this application as a product so we keep on enhancing/adding new fetaures by way of adding new options on each form, reports etc. Now with any modictaion/corrections many times a new bug appears. Is there any way we can automate the testing, such that we can test the functionality / output using some predefined test cases?
For eg in many cases while adding a new text box, focus is not proper?
May be while adding a new text box the data saving logic might be corrupt so that a wrong field in wrong column?
Thanks and Regards
Amit
|
|
|
|
|
Tools like QTP[^] can automate the test processes. You can also write test cases that will test the whole functionality. These test cases can be executed by a testing framework like NUnit. For all the new code that you add, make sure you have automated unit test cases for each functionality.
Best wishes,
Navaneeth
|
|
|
|
|
how to make remote desktop with c#, i don't understand, i'm beginner, please help me.....
thank you very much....
|
|
|
|
|
before you post you must Google
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
It took me less than 5 seconds to find this[^] article - you need to work on your Google skills because I copied remote desktop with c# into Google and the resulting list of webpages contained everything you need.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Hi, i want to set formatted Html to the clipboard using c#. The formatted html contains colored texts,
tables etc. What i wrote is:
DataObject dataObject = new DataObject();
dataObject.SetData(DataFormats.Html, true, htmlString);
Clipboard.SetDataObject(dataObject);
Then i ran the program and tried to paste the data in MSWord. But nothing is pasted. If i set DataFormats.Text, then data is pasted without any problem. But this time only the whole html string with tags are pasted as plain text. I want formatted html.
So how can i do that?
Thanks in advance.
|
|
|
|
|
hi all,
i m a Beginner,please give me a suggestion about Which book learning C # better
thanks to all!
|
|
|
|
|
|
thanks very much,but where can i download XPS reader?
|
|
|
|
|
miss YY wrote: where can i download XPS reader?
I think that comes free with Microsoft Vista and Windows 7, so I would guess from Microsoft. Personally I go for the PDF version as there are lots of good free PDF readers available.
|
|
|
|