Click here to Skip to main content
       

C#

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page  Show 
GeneralRe: Index was outside the bounds of the array.memberErol230913 Jan '13 - 4:17 
wow....that was just to stupid....sorry...thanks alot!!! I really apreciate
GeneralRe: Index was outside the bounds of the array.mvpOriginalGriff13 Jan '13 - 4:21 
As I said - we've all done it!
 
(I tend to read what I meant to write which doesn't help... Wink | ;) )
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.

AnswerRe: Index was outside the bounds of the array.memberPIEBALDconsult13 Jan '13 - 4:41 
I think it was nearly OK before -- I find removing items from a list in reverse is easier -- but you would need to use
for ( int i = count-1; i >= 0; i--)
QuestionObject reference not set to an instance of an objectmemberErol230912 Jan '13 - 19:25 
Hello
 
I am trying to use a method that reads all the values from a subkey but something seems to be wrong...can anyone tell me the corect way to do it?
 
<pre lang="c#">public string[] ReadValues(string rkey)
        {
 

            
            RegistryKey key = Registry.CurrentUser.OpenSubKey(rkey);
            string[] VNames = key.GetValueNames();
           string[][] values = new string[VNames.Length][];
           string[] v = new string[VNames.Length];
            for (int i = 0; i < VNames[i].Length; i++)
            {
                
                values[i][0] = VNames[i];
                values[i][1] = (string)key.GetValue(VNames[i]);
                v[i] = values[i][1];
 
            }
            return v;
 
        }

AnswerRe: Object reference not set to an instance of an objectmemberjibesh12 Jan '13 - 19:41 
this is one of the easiest exceptions can be resolved by debugging your application. put a break point at this line
 RegistryKey key = Registry.CurrentUser.OpenSubKey(rkey); 
and debug your application.
 
most possible case is key or VNames variable is be null.
Jibesh V P

QuestionSaving selected option into databasememberOyebisi Jemil12 Jan '13 - 11:31 
i am building an online based Examination project using asp.net, when the student click an option the option should be stored into database, and if the student which to edit the answer, he or she should be able to do click previous   button and edit it.
AnswerRe: Saving selected option into databaseprotectorPete O'Hanlon12 Jan '13 - 11:45 
Very good. I'm delighted for you. I am so pleased that I am going to have to have a lie down now.

*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

"Mind bleach! Send me mind bleach!" - Nagy Vilmos

CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

AnswerRe: Saving selected option into databasemvpDave Kreskowiak12 Jan '13 - 12:48 
...and the question would be ...... ???

GeneralRe: Saving selected option into databasememberBrisingr Aerowing12 Jan '13 - 13:49 
The question is what the question is!

Bob Dole
The internet is a great way to get on the net.

D'Oh! | :doh: 2.0.82.7292 SP6a

GeneralRe: Saving selected option into databasememberPIEBALDconsult12 Jan '13 - 15:22 
What is the sound of one neuron firing?
QuestionBinary Readermemberdxtrx12 Jan '13 - 10:38 
Is there a way to tell the binary reader how many characters to read because i need the code to read certain amount of bytes in every row of the code and this code i want to read the first row i need to read only 10 Bytes and not the whole row
 
this is a part of the code that reads from the file
string emriK = brHuazimet.ReadString();
 
now i know how to write this string into the file i am going to write after reading this part but when i try to read it reads to much from the code
 

If u need any more explanation let me know
AnswerRe: Binary Reader [modified]memberjibesh12 Jan '13 - 13:01 
Yes its possible to read selected no of byte. Use the Read method instead of ReadString. check
here for Read Syntax[^]
 
/Edit Sorry I dont know what happend I just updated the link path again
Jibesh V P


modified 13 Jan '13 - 0:45.

GeneralRe: Binary Readermemberdxtrx12 Jan '13 - 13:17 
there is nothing in that link :S
GeneralRe: Binary ReadermemberBrisingr Aerowing12 Jan '13 - 13:48 
Try this.[^]

Bob Dole
The internet is a great way to get on the net.

D'Oh! | :doh: 2.0.82.7292 SP6a

QuestionSocket programming- Response to all client [modified]membermohammadkaab12 Jan '13 - 7:36 
hi guys . i have many client that are connected to the server .
i can connect to the server completely with out any wrong in my code from my clients .
and the server response the client pretty fine .
okay , what do i need to do , is that if one client send some data to the server , i need the server to response to all the clients . like
 
Server/Client []
 
now the server just can respond the client that send the data .
 
any help i'll be greatfull.
i hope you got what i mean .

modified 12 Jan '13 - 13:57.

AnswerRe: Socket programming- Response to all client [modified]memberpt140112 Jan '13 - 8:21 
My advice is the same as I offer in response to most socket-related programming questions: don't roll your own, there's no point. Socket code is hard to write well and even harder to test thoroughly.
 
Instead, spend a bit of time getting your head around ZeroMQ[^]. Trust me, it will be time well spent. What you are trying to do is easily achieved with ZeroMQ. Look at the dealer-router & publish-subscribe patterns. I think this is the sort of thing you're after (taken from the ZeroMQ Guide) :-
 
https://github.com/imatix/zguide/raw/master/images/fig59.png[^]
 
Just to show how easy things can be with ZeroMQ, here's the complete code for a bare-bones chat client & server console app that does basically what you're after.
 
First, the server:-
using System;
using System.Text;
using ZeroMQ;
 
namespace ChatServer
{
    class Server
    {
        // Call with ChatServer.exe <router_ep> <publish_ep>
        // eg. ChatServer tcp://127.0.0.1:5000 tcp://127.0.0.1:5001
        static void Main(string[] args)
        {
            ZmqDealerSocket dealer = new ZmqDealerSocket();
            dealer.Bind(args[0]);
 
            ZmqPublishSocket publisher = new ZmqPublishSocket();
            publisher.Bind(args[1]);
 
            dealer.OnReceived += delegate(Byte[] bytes, bool multipart)
            {
                Console.WriteLine("Received from client: " + Encoding.UTF8.GetString(bytes));
                publisher.Send(bytes);
            };
 
            while (true)
                System.Threading.Thread.Sleep(1000);
        }
    }
}
 
...and the Client :-
using System;
using System.Text;
using ZeroMQ;
 
namespace ChatClient
{
    class Client
    {
        // Call with ChatClient.exe <dealer_ep> <subscribe_ep> <name>
        // eg. ChatClient tcp://127.0.0.1:5000 tcp://127.0.0.1:5001 Dave
        static void Main(string[] args)
        {
            ZmqDealerSocket dealer = new ZmqDealerSocket();
            dealer.Connect(args[0]);
 
            ZmqSubscribeSocket subscriber = new ZmqSubscribeSocket();
            subscriber.Connect(args[1]);
            subscriber.Subscribe("");
 
            subscriber.OnReceived += delegate(byte[] bytes, bool multipart)
            {
                string[] msg = Encoding.UTF8.GetString(bytes).Split('|');
 
                Console.WriteLine(String.Format("{0}: {1}", msg[0], msg[1]));
            };
 
            while (true)
                dealer.Send(args[2] + "|" + Console.ReadLine());
        }
    }
}
 
Finally, a batch file, test.bat, to demo it...
start "Server" cmd /T:8F /k ChatServer.exe tcp://127.0.0.1:5000 tcp://127.0.0.1:5001
start "Jim" cmd /T:8E /k ChatClient.exe tcp://127.0.0.1:5000 tcp://127.0.0.1:5001 Jim
start "Dave" cmd /T:8E /k ChatClient.exe tcp://127.0.0.1:5000 tcp://127.0.0.1:5001 Dave
start "Pete" cmd /T:8E /k ChatClient.exe tcp://127.0.0.1:5000 tcp://127.0.0.1:5001 Pete
 
How easy could it be??? Big Grin | :-D
Let me know if you want the VS2010 solution zip & ZeroMQ wrapper DLL I used...

modified 13 Jan '13 - 7:30.

GeneralRe: Socket programming- Response to all clientmemberjschell14 Jan '13 - 8:26 
pt1401 wrote:
Instead, spend a bit of time getting your head around ZeroMQ[^].

 
Interesting.
 
Have you used it in any high volume systems? Where that would be proven production performance or realistic performance profiling?
GeneralRe: Socket programming- Response to all clientmemberpt140114 Jan '13 - 19:51 
Nope, not personally, though many people have. We use it to pass messages between sites on our EPOS systems, but it's low-volume stuff.
 
ZeroMQ is very fast. Here[^] are the official performance tests on the ZeroMQ site, and this[^] is a performance comparison between RabbitMQ, ZeroMQ and QPid on Apache. ZeroMQ was over 60 times faster than RabbitMQ and 250 times faster than Qpid. Note, however, that these tests were a C++ application. Putting a C# wrapper around ZeroMQ slows it down somewhat, but makes it *so* easy to use Smile | :)
 
UPDATE: The RabbitMQ/ZeroMQ/Qpid test in the link above may not have been fair - see the comments regarding whether message persistence was enabled. Final opinion seems to be use ZeroMQ for socket comms but if you need an MSMQ-type message queue with message persistence use an AMQP app like RabbitMQ...
GeneralRe: Socket programming- Response to all clientmemberjschell16 Jan '13 - 8:53 
pt1401 wrote:
are the official performance tests on the ZeroMQ site

 
Unfortunately I don't place much credence on benchmarks. Real world stuff is always more messy.
GeneralRe: Socket programming- Response to all clientmembermohammadkaab15 Jan '13 - 3:15 
hi , ty for this info , they have really help me out . im wondering if you can send it to me by this gmail mohammad.kaab@gmail.com.
ty
GeneralRe: Socket programming- Response to all client [modified]memberpt140115 Jan '13 - 4:01 
Done - enjoy...
UPDATE: Your gmail address bounced - can you confirm the address please?
UPDATE2: https://skydrive.live.com/redir?resid=9D275D4F238CCC77!154&authkey=!ABAZKbMqZxNKI9Y[^]

modified 15 Jan '13 - 10:51.

GeneralRe: Socket programming- Response to all clientmembermohammadkaab15 Jan '13 - 7:37 
hi im sorry for bothering you with my stupid question .
 
Server :
ZmqDealerSocket dealer = new ZmqDealerSocket();
            dealer.Bind("tcp://127.0.0.1:8000");
 
            ZmqPublishSocket publisher = new ZmqPublishSocket();
            publisher.Bind("tcp://127.0.0.1:8200");
Client_1 :
 ZmqDealerSocket dealer = new ZmqDealerSocket();
            dealer.Connect("tcp://127.0.0.1:8000");
 
            ZmqSubscribeSocket subscriber = new ZmqSubscribeSocket();
            subscriber.Connect("tcp://127.0.0.1:8200");
Client_2:
ZmqDealerSocket dealer = new ZmqDealerSocket();
            dealer.Connect("tcp://127.0.0.1:8000");
 
            ZmqSubscribeSocket subscriber = new ZmqSubscribeSocket();
            subscriber.Connect("tcp://127.0.0.1:8200");
 
did i bind it right or ... Big Grin | :-D
GeneralRe: Socket programming- Response to all clientmemberpt140115 Jan '13 - 8:37 
Yep, looks good to me.
GeneralRe: Socket programming- Response to all clientmembermohammadkaab16 Jan '13 - 1:38 
hi , i didnt asked my qustion in public bcz i know it takes too much time for getting the result .
 
i have make an execute program of the project that i has made with visualstadio 2010 .
i have setup it on my windows 7 , and it works fine.
but when im setup it in windows xp it'll give me an error
 
unable to load Dll 'libzmq' hresult 80070007h , and sth like this
but i have already attach the file libzmq , and why it didnt throw an error in windows 7 ?
should i attach any other dll to my project .
ty for any help .
GeneralRe: Socket programming- Response to all clientmemberpt140116 Jan '13 - 1:52 
It would help to know exactly what was contained in "and sth like this".
 
I suspect it was a BadImageFormatException beng thrown. The file libzmq.dll is a C++ library and therefore can't be loaded if you compile your project for 'AnyCPU'.
 
You need to compile for either x86 ot x64 when using C++ libraries, not for AnyCPU.
 
The version of libzmq.dll that I posted is the x86 version, so you need to compile your project for x86. It'll run on both x86 & x64, but you need to compile for x86.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   


Advertise | Privacy | Mobile
Web03 | 2.6.130523.1 | Last Updated 25 May 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid