|
Hi,
I have an TCP server client application, with client running on the WM 6.0.
I have using TcpClient class to establish connection to my server and send data. If I am using wifi the code is working fine, but if I am trying to use GPRS its not working. I think I have to start GPRS connection first. Can someone please tell me how to fix this.
here is the client side code
public class Client
{
public void GpsClient(string Ostring)
{
TcpClient socketForServer;
try
{
socketForServer = new TcpClient("energystudy.dyndns.org", 13000);
}
catch
{
Console.WriteLine("Failed to connect to server at {0}:13000", "energystudy.dyndns.org");
return;
}
NetworkStream networkStream = socketForServer.GetStream();
System.IO.StreamReader streamReader = new System.IO.StreamReader(networkStream);
System.IO.StreamWriter streamWriter = new System.IO.StreamWriter(networkStream);
try
{
string outputString;
// read the data from the host and display it
{
outputString = streamReader.ReadLine();
//Console.WriteLine(outputString);
streamWriter.WriteLine(Ostring);
//Console.WriteLine("Client Message");
streamWriter.Flush();
}
}
catch
{
Console.WriteLine("Exception reading from Server");
}
networkStream.Close();
}
}
|
|
|
|
|
I'm trying to understand the different compiler options in C#.
What exactly is JIT? Is JIT implemented by default or is there a different "default" compiler?
I'm not quite clear on the C# compiler options, relationships and differences. Please explain.
|
|
|
|
|
I recommend doing some reading on the MSDN site. JIT stands for just in time. The C# compiler creates machine code for each part of your program, when it gets run for the first time. There's no other options I know of, excepting that you can buy expensive tools that compile to machine code ( and thus do not need the .NET framework ) all in one go.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
So each language has its own compileer, right? One for C++, one for VB, one for C#? I assume that each of these compilers has its own JIT functionality. Is this correct?
So is JIT simply a feature of a compiler rather than a type of compiler?
I have read that the C++ compiler supports function inlining but the C# compiler does not. Has MS updated the C# compiler to support function inlining or does function inlining still not exist in the C# compiler? If not then why not?
|
|
|
|
|
Member 3919049 wrote: I assume that each of these compilers has its own JIT functionality. Is this correct?
No, C++ is a different kettle of fish, unless you use C++/CLI. The compiler is actually in the framework.
Member 3919049 wrote: I have read that the C++ compiler supports function inlining but the C# compiler does not
Possibly. One thing to be clear on here - C++ function inlining does not mean you control it. The compiler can choose to inline something without you asking for that, and it can ignore your request. This is part of the c++ standard.
Member 3919049 wrote: Has MS updated the C# compiler to support function inlining or does function inlining still not exist in the C# compiler?
What you need to understand is, the C# compiler works totally differently to the C++ one. There is no inlining in C#.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thanks Christian - You really know .NET quite well.
Is there any reason why the C# compiler does not do function inlining?
It seems like function inlining would provide a big performance improvement and it seems like MS has already done the work to define this logic for the C++ compiler so it doesn't seem like it would be too complicated to implement similar logic in the C# compiler....
|
|
|
|
|
Member 3919049 wrote: Is there any reason why the C# compiler does not do function inlining?
I guess they didn't bother to add it.
Member 3919049 wrote: It seems like function inlining would provide a big performance improvement
In very rare cases, perhaps.
Member 3919049 wrote: it seems like MS has already done the work to define this logic for the C++ compiler
The logic is trivial, actually.
Member 3919049 wrote: so it doesn't seem like it would be too complicated to implement similar logic in the C# compiler....
It would be trivial for them to give optional parameters in C#, but have they ? I don't know why.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Christian Graus wrote: I guess they didn't bother to add it.
The C# compiler won't do that kind of thing to preserve reflection capabilities, I believe. Inlining happens at the JIT level[^].
For more info, see Eric Gunnerson's Why Doesn't C# have an inline keyword?[^]
Life, family, faith: Give me a visit.
From my latest post: "How differently the psalmist saw it! How blessed -- how truly happy with real joy! -- is the man who delights in the Law of the Lord."
Judah Himango
|
|
|
|
|
Hi All,
I have a datatable with some data :
ActivityNr ActivityStartTime ActivityDuration
001 20:30 00:30
002 20:30 00:40
003 20:30 00:20
As you can see, activity 002 has a longer Duration(40 minutes) then Activity 001(30 minutes) and activity 003(20 minutes).
How can i delete the activities with shorter 'ActivityDuraton' from the datatable and keep the one with the longest 'ActivityDuration???
Assuming the datatable above, the end resulat most be:
ActivityNr ActivityStartTime ActivityDuration
002 20:30 00:40
Thanx.
|
|
|
|
|
Didn't you ask this the other day ? I think you need to ask in the SQL forum, b/c you're asking how to write a query to get these values, right ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
hi friends,
i have a program which is for locking the screen (disappers the start menu and other windows) and the form of program appears and wants a password to login and then allows the user to continue his work.
in that program, the programmer has used user32.dll and kernel32.dll by DllImport class.
but the problem is that it works if you are a member of administrators. when i change my group to power users and run the program, an error appears ("an error occured, tell this to microsoft") and the program exits.
i have changed the security accesses of power users from the 'security' tab of windows xp (i have changed access of user32.dll and kernel32.dll in %windir%\system32\ to 'full control') but nothing changed and error again appeared when i run the program in a power user account.
what should i do if i want to use such programs (which uses DllImport) in non-administrator account?
thanks
modified on Tuesday, June 10, 2008 4:55 PM
|
|
|
|
|
You don't need to be an admin to use dll import. You probably need to be one to use the APIs you are calling.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
thanks for your consideration,
you mean the problem can not be solved in any way?
what should i do to solve this problem?
is the problem for that *.Dll s?
how can i solve my problem then?
thanks again
|
|
|
|
|
Sajjad Izadi wrote: is the problem for that *.Dll s?
No, the problem is that you've chosen to call APIs that only work for an admin. You need to find a different way to do what you're trying to do, read the docs on the APIs you're calling and see which ones require admin, then find a differernt way.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
|
Quit Double Posting[^]
Don't be overcome by evil, but overcome evil with good
|
|
|
|
|
Hi friends,
I had a website running in my local computer with no problem. When I tried to uploaded to my server all the DB permissions were messed up. I tried to reproduce the error in my local PC but I ended up messing up my site config,
I'm using memberships to manage accesses to my site. I want to create a website from scratch so I will have a brand new ASPNETDB database. How can I do this? I have created several new websites in different folders in VS but that only created the App_Data folder with no database in it.
How can I start from scratch???
Thanks a lot
|
|
|
|
|
I have a class SubClass that inherits from class Base.
I have an array of type Base that I want to serialize. So, that the serializer knows about all the possible subclasses, I called the constructor like so:
XmlSerializer s = new XmlSerializer( ObjectType, extraTypes );
where extra types is an array of types that includes SubClass.
When I make this call to the constructor, I get the exception:
Outer exception: There was an error reflecting type 'Subclass'
Inner exception: Types 'Subclass' and 'Subclass' both use the XML type name, 'Subclass', from namespace ''. Use XML attributes to specify a unique XML name and/or namespace for the type.
There clearly aren't two classes with the same name or my code wouldn't have compiled.
Any thoughts on what my problem could be?
modified on Tuesday, June 10, 2008 3:03 PM
|
|
|
|
|
Eric Burns wrote: Any thoughts on what my problem could be?
Dump the xml schema from the Type/Graph and see why 2 different types are created.
|
|
|
|
|
I have a Node that has a collection of Labels. The user can click on the node and view the properties in a PropertyGrid. If the user clicks on the collection of labels they can add/remove labels via the Collection Editor.
How do i listen for when the user has added a new label to the collection?
Regards,
Gareth.
(FKA gareth111)
|
|
|
|
|
Gareth H wrote: How do i listen for when the user has added a new label to the collection?
What version of .NET are you in. AFAIK in 2.0 there are no notifications. The form makes a local copy (or even more than one) of the collection and modifies the copy and returns it to you (if I remember correctly). The way I dealt with that was I made my own form that was an exact duplicate of the built in one and added my own events to it, like OnAdd, OnDelete, OnChange or some such. Oh, also it modified directly the collection you gave it.
If you find a better way, particularly if something is added in 3.X, please a reply to me. Thanks.
led mike
|
|
|
|
|
led mike,
I am using .NET 3.5. I will carry on looking and tell you if i find anything.
Regards,
Gareth.
(FKA gareth111)
|
|
|
|
|
I had some code in a Button event that took for ever to run causing my main form to freeze. To get past this I have now decided to move the processing to a sepperate Thread instead. Now I have a problem with the ProgressBar which gives me the below error when running the application.
Cross-thread operation not valid: Control 'Form1' accessed from a thread other than the thread it was created on.
Below is how I have changed the Button event and the start of my new thread.
private void btnRun_Click(object sender, EventArgs e)
{
Thread excelrun = new Thread(RunExcel);
excelrun.Start();
lblPercent2.Visible = true;
lblRecordProcessed.Visible = true;
lblProgText.Visible = true;
lblProgress.Visible = true;
}
And now the start code of the Thread.
private void RunExcel()
{
string filepath;
filepath = txtboxSelectTxtFile.Text;
FileHelperEngine<readfile> engine = new FileHelperEngine<ReadFile>();
engine.ErrorManager.ErrorMode = ErrorMode.SaveAndContinue;
ReadFile[] res = engine.ReadFile(filepath, 1);
ReadFile[] mes = engine.ReadFile(filepath);
int progrval = 0;
progrval = progressBar1.Value;
progressBar1.Minimum = 0;
progressBar1.Maximum = engine.TotalRecords;
progressBar1.Visible = true;
</readfile>
Any help would be appreciated.
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
This question gets asked a couple times a week in this forum. Did you try searching for your error message?
Short answer: you can access controls only from the thread that created them.
Longer answer: use a BackgroundWorker component to do your work. It has a ProgressReported and RunWorkerCompleted event which you are allowed to access your controls on.
Life, family, faith: Give me a visit.
From my latest post: "How differently the psalmist saw it! How blessed -- how truly happy with real joy! -- is the man who delights in the Law of the Lord."
Judah Himango
|
|
|
|
|
Thanks for the reply. I always search for answers before I ask but I get nothing returned when searching. Thanks again for the help. Much appreciated.
Excellence is doing ordinary things extraordinarily well.
|
|
|
|