|
Many thanks.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Hi,
I apologize if this question is in the wrong place.
I inherited a C# windows service from a previous developer but I am having some trouble with his code. It is a windows service that can have classes loaded into it without having to recompile the service. I am assuming this is done by the windowsservice.exe.config file, specifically the
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="currencyworker" culture="neutral" publicKeyToken="null"/>
<codeBase version="1.1.0.0" href="currencyworker.dll"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
A second config file gives the name of the class and its namespace. The windows service takes that info and uses the Type.GetType(typeName); function on it and then instantiates it. The problem I am having is that the .GetType function keeps returning null when I start the service leading me to believe that my syntax or something else is wrong with the windowsservice.exe.config file and that the class(currencyworker.currency in my case) is not being loaded. I have gotten it to work before but its rather random and not consistent so I can't seem to locate what is going wrong. Any help on this would be great, my understanding of this is not high so I am sorry if this doesn't make sense or is confusing.
|
|
|
|
|
|
A Type name in a configuration file should be case-sensitive and fully qualified. That means that you need the namespace and the assembly name of the assembly its contained within:
Name.Space.CurrencyWorker, Name.Space
Assuming that a type CurrencyWorker exists in assembly Name.Space.dll or Name.Space.exe.
|
|
|
|
|
hi
how to close all the running application like
word , notepad ,photoshop .....etc
and thanks
|
|
|
|
|
....
"Well, we're getting "F"'d at work. WPF, WCF, and WWF... WTF?" --John Simmons
|
|
|
|
|
abu rakan wrote: how to close all the running application like
word , notepad ,photoshop .....etc
Shut down windows. That will close all the applications - and in a very green environmentally friendly way that uses very little power.
|
|
|
|
|
thanks
but want make that witout shutdown XP
|
|
|
|
|
Over a month and you STILL can't figure this out? Nevermind searchin google, CP articles or even the message board would have given you the answer.
Ugh. I got so tired of this I gave up and coded it for you.
Here is the damn code.[^]
|
|
|
|
|
thank you
if you woudnot to replay
dont replay
i didnot ask you
|
|
|
|
|
blank[] blanklist = blank.Getblank();
foreach(blank theblank in blanklist)
{
theblank.blank();
}
If you can't figure it out, then go stupid business or some crap.
|
|
|
|
|
When you ask the same question over and over, when you have already been given the solution or told to Google an easier type of question you are going to get flamed. Now, if you want to be rude in your replies NO ONE WILL EVER HELP YOU AGAIN.
Do you understand this?
"Well, we're getting "F"'d at work. WPF, WCF, and WWF... WTF?" --John Simmons
|
|
|
|
|
Windows doesn't have a utility to do this. You'll have to be a programmer and write one.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I'll probably get flamed for this, but I'm responding in the hope that you'll then go away.
What you want to do shouldn't be done - it's not your computer it's the users. They get to decide when their open applications should close. (Hint to possible solution later)
You've previosly asked about stopping running processes - again, you should not do this for the above reasons, plus some may be important to the system and could potentially hang the system totally if stopped.
You've also asked about stopping Explorer. The only valid reasons to do this are if Explorer has crashed in which case your C# program will not be accessible until it's restarted, or if you're writing your own shell - which can't be done in C#.
So - don't attempt to do any of these.
The first however may be acheivable using FindWindow and DestroyWindow from user32.dll. Have a look on pinvoke.net for more info.
Now stop asking the same/rephrased question - do some coding and post back only with specific problems in your code.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
|
I am using C# 2008 express. When I do a textBox.Text.Length it does not count escape sequence characters in the string ex."\r\n" has length of 2 instead of 4. I am trying to have a console window show what line of a file I am sending, I use the Text.Remove command to remove the previous string that displays the last count, and append the new string that show the current count.
Ex..
textBoxConsole.Text = "Sending File....\r\n";
int len = textBoxConsole.Text.Length;
for (int i = 0; i <= 3; i++)
{
textBoxConsole.Text.Remove(len - 1);
textBoxConsole.AppendText("Line 1 of 3");
}
The above code will produce the following string:
"Sending File....\rLine 1 of 3"
The "\n" is cut off because the length was not correct. If there is more text above this more characters will be cut off because of ignored "\"s.
If anybody has a better way to do this please let me know.
Thanks!
|
|
|
|
|
Escape sequences like \r and \n are for the programmer and are converted to their proper one character representation (0x0d and 0x0a, in this case). If you want the length of the string, then assign the string to an intermediate variable first and get the length from that.
string message = "Sending File....\r\n";
int len = message.length;
textBoxConsole.Text = message;
for (int i = 0; i <= 3; i++)
{
textBoxConsole.AppendText("Line 1 of 3");
}
Hope this helps!
Jon
|
|
|
|
|
Thanks for the reply.
When I run your code the length of message is reported as 18, not 20. If I put another "\r\n" at the end of the string and it is reported as 20 not 24. Ignoring all "\"s in the string.
I need this so I know what position I am in the string so I can remove the previous string "Line 1 of 3" and replace it with the new string "Line 1 of 2". While keeping any text already in the console. I am sending thousands of lines so I can't append them into the console.
I tried to copy the textbox.Text to a string and get the length, same results.
Thanks!
|
|
|
|
|
asquaredtech wrote: When I run your code the length of message is reported as 18, not 20. If I put another "\r\n" at the end of the string and it is reported as 20 not 24. Ignoring all "\"s in the string.
It isn't ignoring the slashes. The slashes indicate the start of an escape sequence. The slashes are interpreted by the compiler as if to say this and the next character represent something other than what is displayed in the source code.
In other words, treat the "n" in "\n" as the new line character rather than as an "n".
"\t" is the representation of the tab character (singluar) becuase it is difficult to represent that in code.
"\r\n" represent the character pair carriage return and newline. Although you put four characters in the source code, there are only two character actually generated in the compiled output.
If you do actually need to represent a slash character in a string in your source code then use "\\".
asquaredtech wrote: I need this so I know what position I am in the string so I can remove the previous string "Line 1 of 3" and replace it with the new string "Line 1 of 2". While keeping any text already in the console. I am sending thousands of lines so I can't append them into the console.
One thing you could do is this. If you are displaying this on the Console , use Console.Write and finish your string with "\r" which is a carriage return. Without the newline that normally comes with it, it will return you to the start of the current line. You then overwrite the text that already exists on that line.
Many console applications use this technique when displaying progress status.
|
|
|
|
|
asquaredtech wrote: "\r\n" has length of 2 instead of 4
That count is correct. There are two characters in the string "\r\n", not four.
asquaredtech wrote: The "\n" is cut off because the length was not correct.
What (int) does the .Length method return when you measure the length of the string in the debugger?
"Sending File....\r\n".Length = 18? You expected it to be 20, right?
asquaredtech wrote: textBoxConsole.Text.Remove(len - 1);
..is this the place where your string is a character short?
I are troll
|
|
|
|
|
"T\r\n" : Len = 3, not 5
"T\r\n\r\n" : Len = 5, not 9
All "\"s are not being counted.
I subtract 1 because the .Length is 1 based, the index into the string is 0 based.
Thanks!
|
|
|
|
|
asquaredtech wrote: I subtract 1 because the .Length is 1 based, the index into the string is 0 based.
That is not correct. The length is zero based, a one based length would not make sense.
The value 4 means four characters, not three.
Also, if the length really would have been one based, you would have to add one to the value instead of subtracting one.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Thank you for repeating what I said.
1 based = 1,2,3,4
0 based = 0,1,2,3
length of 4, 4th character has an index of 3 in the string b/c the first items index is 0.
which is why i subtract 1. if I want to remove characters after the 4th character, I send an index of 3.
|
|
|
|
|
asquaredtech wrote: Thank you for repeating what I said.
No, I didn't. What you say doesn't make sense.
asquaredtech wrote: if I want to remove characters after the 4th character, I send an index of 3.
No, you don't. If you send an index of 3 you will not remove characters after the fourth character, you will remove characters from and including the fourth character.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi,
1.
the lengths are correct, each character counts as 1, and of course every escaped character such as "\r" and "\n" is one character.
2.
The code you have shown and the description of the symptoms don't fit together:
String.Remove does not modify an existing string, it returns a new one; strings are immutable, you cannot change them, you can only replace them by another string. Hence your Remove statement does not achieve a single thing.
3.
If your output is line-oriented, i.e. each line is a statement and nothing needs to wrap around, then
I strongly suggest using a ListBox rather than a TextBox. It is much faster, and much easier to program
since it handles individual items without needing any concatenation (and no \r \n)
Remark: if you ever want to copy text from your XxxBox, a ListBox only supports integral-line selections,
and you then would have to do the concatenation programmatically.
|
|
|
|