|
alok_2k3 wrote: I am reposting this message,
Don't do that. It is rude. If someone has an answer for you, they will eventually reply. Reposting the same message over and over doesn't accomplish anything but irritated people...
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
I don't agree with you. The other day, a person reposted a question to which he did not get an answer, in the hope that he would get one this time.
I happened to see his question that time and was able to answer it. At least, they stay polite by mentioning the repost fact.
|
|
|
|
|
Le Centriste wrote: a person reposted a question to which he did not get an answer, in the hope that he would get one this time
That doesn't do much good except flood the forums with redundant posts.
The very reason Chris put View unanswered questions in the C# forum in each forum, so posts that haven't received any replies don't get lost.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hello,
I hope somebody has a good explanation for this issue.
Okay I'm having troubles with the httpWebRequest method. I need to download reports from a specified server (can't give these details). Now I don't have trouble with an "HTTPS" url but I with an "HTTP" url I get the error :
error: The server committed a protocol violation. Section=ResponseHeader Detail=Header name is invalid
This the first time I got this error in c#.net. I tried this in Java and there I didn't had any problems. So I'm kind of lost.
I search the internet to see what the "ProtocolViolationException" throws. I found this on the msdn site:
ProtocolViolationException :
Method is GET or HEAD, and either ContentLength is greater or equal to zero or SendChunked is true.
-or-
KeepAlive is true, AllowWriteStreamBuffering is false, ContentLength is -1, SendChunked is false, and Method is POST or PUT.
I did an output of these properties and some how these don't have the values mention to trigger the ProtocolViolationException.
So my question is, How is this possible?
this is my testClass:
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Net;
namespace adlogix_views
{
static class httpTestClass
{
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
string page = "";
try
{
// write a line of text to the file
HttpWebRequest wr = (HttpWebRequest)WebRequest.Create("http://www.mywebsite.com");
string userPass = "myUsername:myPassword";
string encoding = Convert.ToBase64String(Encoding.ASCII.GetBytes(userPass));
wr.Headers.Add("Authorization", "Basic " + encoding);
wr.PreAuthenticate = true;
Console.WriteLine("Method = " + wr.Method);
Console.WriteLine("ContentLength = " + wr.ContentLength);
Console.WriteLine("SendChunked = " + wr.SendChunked);
Console.WriteLine("KeepAlive = " + wr.KeepAlive);
Console.WriteLine("AllowWriteStreamBuffering = " + wr.AllowWriteStreamBuffering);
HttpWebResponse ws = (HttpWebResponse)wr.GetResponse();
Stream str = ws.GetResponseStream();
StreamReader sr = new StreamReader(str);
while ((page = sr.ReadLine()) != null)
{
Console.WriteLine(page);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
}
this is the output of the properties
output: Method = GET
ContentLength = -1
SendChunked = False
KeepAlive = True
AllowWriteStreamBuffering = True
I hope somebody can help me with this.
|
|
|
|
|
Hi
I am passing data between SQL 2005 and a CLR stored procedure developed in C# via the Service Broker, which uses XML as its transport. It's posted here as the problem is more C# than SQL. The message is read in the C# stored procedure using an SQLDataReader.
The value, a string, is retrieved from the reader as an array of bytes.
byte[] mystring = (byte[])myReader[2];
mystring is populated with the ascii values of each character in my string, but interspersed with nulls ( 0s ), the equivalent of
byte[] mybytes = {53,0,49,0,50,0,57,0}; I can't seem to encode this back to a string. I've tried straight ASCIIEncoding, going via UTF8 (google?) with the following :-
byte[] temp = { 53, 0, 49, 0, 50, 0 , 57 , 0};
byte[] buf = Encoding.Convert(Encoding.GetEncoding("iso-8859-1"), Encoding.UTF8, temp);
string attempt1 = Encoding.UTF8.GetString(buf, 0, 8);
string attempt2 = System.Text.ASCIIEncoding.ASCII.GetString(temp);
What am I missing? To cut a long story short I want to convert byte[] temp = { 53, 0, 49, 0, 50, 0 , 57 , 0}; to a string like "5129" .
I am currently hacking it with a Replace("\0" , "") which is really professional!
Regards
Knowledge is hereditary, it will find its way up or down. - Luc Pattyn
so you answer don't be scared of failure
The only failure is never to try
Things You've Never Done - Passenger -2008
|
|
|
|
|
Don't know if I get the problem exactly, but this seems to work:
byte[] data = { 53, 0, 49, 0, 50, 0, 57, 0 };
byte[] filter_data = Array.FindAll(data, new Predicate<byte>(delegate(byte b) { return b != 0; }));
string s = Encoding.ASCII.GetString(filter_data);
Standards are great! Everybody should have one!
|
|
|
|
|
Thanks - it's similar to my Replace - get rid of the nulls and it works.
I suppose I am asking if a byte[] encoded string should contain two bytes for each character?
And I suppose I should actually go and try that myself!!
Knowledge is hereditary, it will find its way up or down.
Luc Pattyn
and since what every time when i want to add button to this control one add two times
posted in C# forum
|
|
|
|
|
Ah ok. In that case, unicode? This gets the right result...
byte[] data = { 53, 0, 49, 0, 50, 0, 57, 0 };
string s = Encoding.Unicode.GetString(data);
Standards are great! Everybody should have one!
|
|
|
|
|
Bekjong wrote: Ah ok. In that case, unicode? This gets the right result...
Yes it does. How embarrasingly simply was that?
Thank you.
Knowledge is hereditary, it will find its way up or down.
Luc Pattyn
and since what every time when i want to add button to this control one add two times
posted in C# forum
|
|
|
|
|
Glad to help. Not so emarrasing, I've spent most of my day looking for an off-by-one bug.
Standards are great! Everybody should have one!
|
|
|
|
|
I have an object that does work in the background and fires events as certain things happen. If this object is destroyed will the thread be automatically terminated.
I'm guessing that if the thread is not terminated then I need to implement the IDisposable interface and set Dispose() method. I would rather not do this, but I have in the past had code that kept the debugger running because the child thread was still in operation. At the time however I was using
new Thread(new ThreadStart(myThread)).Start()
so I assumed that, while the thread was started from the object, it was not contained within the object's running environment and it was not able to be GCed with the rest of the object.
I implemented a stopping routine when the program was being terminated. However, I am unable to do the same this time.
The thread that is being created is being created as an object
private Thread myThread
so I'm thinking that the thread would be terminated upon the object being destroyed. I certainly hope this is the case.
|
|
|
|
|
No, threads will live until:
* They are finished
* They get an exception and exit
* They are aborted
* Threads with .IsBackground = true will exit when the current process ends
(btw. did I miss something?)
But if you create a thread inside an object, it will not stop just because your object dies.
|
|
|
|
|
A recommended way is to use ThreadPool.QueueUserWorkItem to obtain worker threads for your application rather than creating threads directly. Otherwise you should set Thread.IsBackground = true; This will prevent the app from being held open by any threads that are still running.
only two letters away from being an asset
|
|
|
|
|
There's a property called IsBackground on your thread, if this is set to true the thread will be terminated when your program exits. If you want to stop the thread at runtime you'll have to do this from code: The garbage collection won't clean the object it's running from until the thread's stopped (the thread still holds a reference to its parent container), this doesn't necessarily have to be from an IDisposable implementation though: If you stop the thread and there's no references to its parent object anymore the object will be taken care of by the gc.
Standards are great! Everybody should have one!
|
|
|
|
|
The best solution for this is to use a flag in each thread that when set to true allows the thread to run. When this same flag is set to false, the thread exits. Then in the dispose method, set the flag to false and the threads will exit. This is called a co-operative exit which allows the thread to complete its current task before exiting.
Using thread pool threads to complete your work may seem like a good idea, but one must remember that thread pool threads are not executed if the system is busy. In otherwords, if the work being done in a thread is critical, it should not be put in a thread pool thread.
Using thread.abort() to terminate the thread means that if the thread will be interrupted during its execution and told to terminate. If the task being performed by the thread is critical and must be completed, using thread.abort() will at some point interrupt that task and cause problems.
Phil
|
|
|
|
|
I`m looking for a module that would allow me to do speech recognition. I mean, I want to record some sounds, and then I want to be able to record another sound to see to which of the previously recorder sounds this one fits the best.
Could you recommend me a good solution?
Thank you in advance.
|
|
|
|
|
First of all you should read about the basics of speech recognition - it's far mor complicated than what you seem to think. Wikipedia has some information to start with.
Just trying to "compare two sounds" has been tried (without success) 30 years ago, so I strongly doubt that now you'll succeed with such a simplistic approach.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
U dont understand. I wrote clearly that I`m looking for such module. I don`t intend to write myself.
|
|
|
|
|
Yoyosch wrote: U dont understand. I wrote clearly that I`m looking for such module. I don`t intend to write myself.
You don't understand. It is "wrote clearly" in the forum guidelines that no one will write code for you. You will be hard-pressed to find what you are looking for. I am almost 100% confident that you will have an even harder time finding what you are looking for, free of charge. Learn to use google, you are going to need it to do the research. Good luck
I'm going to become rich when I create a device that allows me to punch people in the face over the internet.
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
|
|
|
|
|
Hi all
I have an inherited control from standard textbox control. In this textbox control i set some default property value to new one.
<br />
this.BackColor = System.Drawing.Color.Red;<br />
<br />
In this case when user place my derived control to a form designer generate in InitializeComponent() this rows
<br />
<br />
((System.ComponentModel.ISupportInitialize)(this.derivedTextBox)).BeginInit();<br />
....<br />
this.derivedTextBox.BackColor = System.Drawing.Color.Red;<br />
<br />
<br />
As a result when form are created DerivedTextBox.BackColor property invoked 2 times. First -
when control created and Second - in the InitializeComponent() method of form where placed.
I know that in this example it dosn't matter but actually i have other base control (not text box), what can add to oneself buttons [for examp: this.Buttons.Add("MyNewButton") - base control by default not have this button, but in derived it shoul be], and since what every time when i want to add button to this control one add two times)
And now i have question, is exists an event what invoked only when control added to a form???
Or where in code i should write initialization control code so as this code will only generated in InitializeComponent() method of form and not to bee invoked when control are created????
THANK.
|
|
|
|
|
if you have a constructor in your derived class then inherit the base class constructor, like:
MyTextBox(): base()
{
}
i think you should use ControlAdded Event
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
How to store files(.doc files,.zip files) in a database and how to retrieve them
|
|
|
|
|
Are you using Oracle or SQLServer database? The concepts are the same for both, but the terminology is a little different.
If you are talking about Microsoft SQL Server then you will be looking at storing and retrieving a BLOB (Binary Large Objects). If you look up Microsoft SQL Server and BLOB you should be able to find all the resources you need to get started.
Try this to start with:
http://support.microsoft.com/kb/309158[^]
Hope this helps
Aaron
_____________________________________________________________________
Our developers never release
code. Rather, it tends to escape, pillaging the countryside all around.
The Enlightenment Project (paraphrased comment)
Visit Me at GISDevCafe
|
|
|
|
|
very thanks for reply me
|
|
|
|
|
IO.Directory.GetFiles("C:\\Windows"); will get me all the files in the windows directory, but is there a way to get all the absolute path names to these files that IO.Directory.GetFiles(path) finds??
|
|
|
|
|