|
Some comments:
1. All too often you don't want to try/catch - a program should have way more try/finally than try/catch. If you're accessing myCommand after the catch ((System.Exception e) {}, myCommand may have not been initialized due to an exception, as you're "swallowing" exceptions on the catch. Notice that if you add a "throw;" statement to your catch, the error message goes away. Be aware that "swallowing" exceptions is a bad practice and leads to code that's hard to debug and problems hard to detect, as the problem will never happen near the real error.
2. If this doesn't solve, you can substitute SqlCommand myCommand; for SqlCommand myCommand = null;
Again, use this wisely, as you can hide exceptions and introduce subtle bugs...
Yes, even I am blogging now!
|
|
|
|
|
Hi!
I've written a windows service. This service can be in different states, for example running, paused, updating etc. To give the user a direct feedback of the services state, I want to display an icon on the windows system tray, which appears in different kind for each state......
The problem is, that the icon (System.Windows.Forms.NotifyIcon) is not displayed... but also no exception is thrown...
<br />
protected override void OnStart(string[] args)<br />
{<br />
NotifyIcon NI=new NotifyIcon();<br />
NI.Icon=new Icon(@" ... ");
NI.Text="My Service";<br />
NI.Visible=true;<br />
}<br />
Can somebody tell me, why my NotifyIcon is not displayed?
occcy
|
|
|
|
|
mabye I am wrong but i think that you should put the NI variable at the calss level. In the code exemple supplied by you NI will be removed (by the garbage colector) at the end of the OnStart function scope.
I hope you understand...
By the way... visit http://nehe.gamedev.net[^]
|
|
|
|
|
A service should not interact with the desktop unless unavoidable, because it could introduce some serious security issues. A sounder design would be the service "talking" to another program that displays the icon.
Don't forget that services run even when there is no desktop, i.e., when no user is logged in.
If you really must do it, there's the "allow service to interact with the desktop" checkbox on the service manager, but I strongly advise you not to use it, unless it's only test code...
Yes, even I am blogging now!
|
|
|
|
|
Okay!
That sounds plausible
Thanks!
occcy
|
|
|
|
|
Hello
I have a question about Microsoft Word events. I know it is possible to catch events cast in Word if you do something like this and start Word through your program.
oWord = new Word.Application();<br />
oWord.Visible = true;<br />
But is it possible to have a program in the "background" and when the user starts Word manually it starts to listen to the events? This sounds impossible to me, but would be nice if it was not
Thanks
|
|
|
|
|
Christer Claesson wrote:
But is it possible to have a program in the "background" and when the user starts Word manually it starts to listen to the events? This sounds impossible to me, but would be nice if it was not
Instead of this, you could write a Word macro or an addin that would call your program only when necessary. This way, your program would not even need to be in "background" all the time, only when needed.
Yes, even I am blogging now!
|
|
|
|
|
Ah, true. I've been looking around and learning about addins now and they seem to be able to do what I want.
Thanks
|
|
|
|
|
Search for "Word addin"
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
helpme
ArrayList al = new ArrayList();
foreach (TreeNode tn in tree.Nodes)
saveNode(tn, al);
}
// Datei anlegen
Stream file = File.Open(filename, FileMode.Create);
Stream file = File.Open(filename, FileMode.);
// Binär-Formatierer init.
BinaryFormatter bf = new BinaryFormatter();
try
{
// Serialisieren des bf.Serialize(file, al);
}
i have succsesful in sava file and unable to reed file help me for purpase
tankyou
|
|
|
|
|
Can you post the code you use for reading the file?
Which specific problems do you have?
www.troschuetz.de
|
|
|
|
|
Try to add the following line before serialization:
bf.AssemblyFormat = FormatterAssemblyStyle.Simple;
This will save the assembly name without the version number, allowing you to read it more easily.
If this works, you should also consider a rigid versioning on this assembly.
Yes, even I am blogging now!
|
|
|
|
|
Hi all,
There are two forms(A and B) in a MDI form container. The form A has a panel(many controls inside the panel). Can form B get the panel from the form A dynamically during its running, so as to display the panel control in form B ?
Thanks
|
|
|
|
|
The answer to your question is no, you can not show a control onto 2 separate forms in the same time... you could acces the panels data instead if you pass it as a parameter to your other form, or by any other way prefered by you...
I hope you understand...
By the way... visit http://nehe.gamedev.net[^]
|
|
|
|
|
Hi all,
In a MDI form container, I tried to add a splitter to seperate two child forms at two different sides (left and right) but failed to do so. What I can do is to use a splitter to seperate a window control(such as panel) and a form, but not two forms, why ?
Thanks
|
|
|
|
|
The MDIParent child client area cannot be split into two seperate client areas. This behavior is by design.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi
Whether exist way to trim from string all occurency of unreadable characters.
Examp:
<br />
string str = "Hello world\t\n...something unreadable else..";<br />
<br />
string res = str.SomeFunction();<br />
<br />
Thank
|
|
|
|
|
|
Thank
But i didn't wont to enum all unreadable characters in some array, and pass one as parameter to Trim. I just wish to invoke some single function to achive my result.
|
|
|
|
|
String.Trim() is a single function I doubt there is colection of whitespace - {space}. What does exactly what you want is reading XML with "ignore whitespace" flag. I'll look how it's done there... wait a moment
David
Never forget: "Stay kul and happy" (I.A.)
|
|
|
|
|
hehe this is how they do it! I've found these functions in url parser, I doubt there is common collection or something like that. If you want single function write it by yourself
ROTOR (Microsoft CLI implemenation) says:
<br />
<br />
PRIVATE inline BOOL IsInsignificantWhite(WCHAR ch)<br />
{<br />
return (ch == TAB ||<br />
ch == CR ||<br />
ch == LF);<br />
}<br />
<br />
#define IsWhite(c) ((DWORD) (c) > 32 ? FALSE : TRUE)<br />
<br />
PRIVATE void TrimAndStripInsignificantWhite(WCHAR *psz)<br />
{<br />
ASSERT(psz);<br />
<br />
if(*psz)<br />
{<br />
<br />
LPCWSTR pszSrc = psz;<br />
LPWSTR pszDest = psz;<br />
LPWSTR pszLastSpace = NULL;<br />
<br />
while(*pszSrc && IsWhite(*pszSrc)) {<br />
pszSrc++;<br />
}<br />
<br />
while (*pszSrc)<br />
{<br />
if(IsInsignificantWhite(*pszSrc)) {<br />
pszSrc++;<br />
} else {<br />
if (IsWhite(*pszSrc)) {<br />
if (pszLastSpace==NULL) {<br />
pszLastSpace = pszDest;<br />
}<br />
} else {<br />
pszLastSpace = NULL;<br />
}<br />
<br />
*pszDest++ = *pszSrc++;<br />
}<br />
}<br />
<br />
if (pszLastSpace) {<br />
*pszLastSpace = L'\0';<br />
} else {<br />
*pszDest = L'\0';<br />
}<br />
<br />
}<br />
}<br />
David
Never forget: "Stay kul and happy" (I.A.)
|
|
|
|
|
|
Hi~
How to remove the control box (The 3 buttons of a window at the top right corner) of a MDI Form?
I have set the formborderstyle to none. However, when I set the form to be maximized, the control box still in there.
How to remove them? Thanks
|
|
|
|
|
|
Try this three Form class properties ControlBox , MaximizeBox , MinimizeBox , you can hide an show them during run time as you wish
I hope you understand...
By the way... visit http://nehe.gamedev.net[^]
|
|
|
|