07.19.07
Posted in Visual Basic .NET at 2:20 pm by Hedwig Lodrigo
What methods are there?
- System.Windows.Forms.Application.Exit() - Informs all message pumps that they must terminate, and then closes all application windows after the messages have been processed. This method stops all running message loops on all threads and closes all windows of the application. This method does not force the application to exit. The Exit method is typically called from within a message loop, and forces Run to return. To exit a message loop for the current thread only, call ExitThread. This is the call to use if you are running a WinForms application. As a general guideline, use this call if you have called System.Windows.Forms.Application.Run.
- System.Environment.Exit(exitCode) - Terminates this process and gives the underlying operating system the specified exit code. This call requires that you have SecurityPermissionFlag.UnmanagedCode permissions. If you do not, a SecurityException error occurs. This is the call to use if you are running a console application.
- End - (Visual Basic only) Terminates execution immediately. The End statement can be placed anywhere in a procedure to end code execution, close files opened with an Open statement, and clears variables at module and class level and all static local variables in all modules. The End statement calls System.Environment.Exit. The End statement stops code execution abruptly, without invoking the Finalize method or any other Visual Basic code. Object references held by other programs are invalidated. The End statement provides a way to force your program to halt. For normal termination of a Visual Basic program, you should unload all forms. Your program closes as soon as there are no other programs holding references to objects created and no code executing.
I want to close the application and I want to close it now
For instance you are handling an exception yourself and want the program to terminate immediately. Then you should do it with Environment.Exit(0)
You would like to exit your windows form based application in a clean way.
You are calling the routine from a menu item. You should use application.exit
Permalink
07.16.07
Posted in Debian, Linux at 10:44 pm by Hedwig Lodrigo
Installing programs without a package manager.
I have been a webmaster for about two years now. But webmaser doesn’t really describe my level of proficiency with managing a linux server.
Truth be told, I got my linux server with LAMP on it out of the box. So I had to install very little on it. It’s a webserver not a desktop.
And when I had to install stuff manually I just wgeted the tar file which was needed, prayed to the gods that be, and did the configure, make and make install.
Now I have a new web server and I’m installing it from scratch and while I was installing some un named obscure software. My friend, which I ‘ll hereafter refer to by the name of Payne, was watching my shell session so he could aid me. And when I did my configure, make, make install routine he uttered NOooooooooo. Turns out that installing it like that is just a bad practice. Many of the thousands of people who ‘ll read this will frown and be slightly stunned, isn’t that how most of the people are doing this?
The good
You should download the source do a
configure
make
Explaining the debuild process is a bit large so I won’t get into it, but to summeraize it:
When you look at your software and you see a debian directory then it has already everything which is needed to turn it into a package with debuild.
You just launch debuild and when everything goes well you get a debian package in the parent directory.
The Bad
configure
make
make install
What makes this bad is that you bypass the package management system. Which means that package management doesn’t know about the
software you just installed. Later on you can install the same software through the packet manager. Then you end up with 2 versions in 2 different locations. The make install method doesn’t take care of dependencies. When you want to uninstall libraries which your make install software depend on
you will get no warning. After you uninstalled it, you will be baffled to find out your ‘make install’ software stopped working. Last problem with this method is uninstalling of the software itself. Other software can depend on it. So when you uninstall this software you can run into the same trouble as mentioned before.
The Ugly
configure –sysconfdir=/etc –prefix /usr/xx
make
checkinstall -D make install
Answer the question ‘The package documentation directory ./doc-pak does not exist.
Should I create a default set of package docs? [y]:’ with ‘y’ .
Enter a description for your package.
Fill in what you like, need. In the end press enter to continue.
Your software is installed and a Debian package is created, you can find in the installation directory.
You can use this package on other pc’s
dpkg -i /path/to/software.deb
Uninstalling can be done by call the dpkg with -r parameter.
dpkg -r the_software
This is the ugly way because your package does not come with dependency checks nor does it come with our of the box init scripts.
Permalink
07.10.07
Posted in Miscellaneous at 4:11 pm by Jonas De Vuyst
Since upgrading to iTunes 7.3, I got the following error when searching iTunes Store for songs: “We could not complete your Music Store request. An unknown error occurred (5002).”
This problem is related to the iTunes shopping cart. To fix, go to edit/preferences/store, activate one-click shopping and press OK. The problem should now be fixed. If you want, you may also now re-enable the shopping cart.
Permalink
07.05.07
Posted in windows at 2:33 pm by Hedwig Lodrigo
When some of your servers are running services which leak memory, you’ll find yourself in the position where you are restarting these services all the time. A good admin will get tired off this very soon and look for a way to automate this.
Automating this is very easy. You can use the windows scheduled tasks to run a bat file.
The bat file has to contain something similar to this:
net stop "ASP.NET State Service"
net stop "FTP Publishing Service"
net stop "ReportServer"
net stop "World Wide Web Publishing Service"
net stop "Simple Mail Transport Protocol (SMTP)"
net stop "IIS Admin Service"
net start "IIS Admin Service"
net start "Simple Mail Transport Protocol (SMTP)"
net start "World Wide Web Publishing Service"
net start "ReportServer"
net start "FTP Publishing Service"
net start "ASP.NET State Service"
When restarting theses services you must lookout for dependencies tho. For instance in the above bat file the World Wide Web Publishing Service depends on the IIS Admin Service. this means you can’t restart the IIS admin Service when the World Wide Web Publishing Service is still running.
Permalink
06.23.07
Posted in Debian, Linux at 2:22 pm by Hedwig Lodrigo
This is a small howto on getting a ftp server on your linux box. After we got it on the box we want to config it. The way we config it is far from a definite guide to security
If you are concerned about security you should not run a common ftp server without sll encryption in the first place. The ftp protocol sends user/password in plain text! That is why I opt not to set the ftp server up with the normal shell logins but with a speparate file in which the ftp users and passwords are stored.
First get the package
apt-get install proftpd
This installs the ftpd server and even creates a default config located at /etc/proftpd.conf.
Open up this file with your favorite text editor. And add the following 2 lines.
SystemLog /var/log/proftpd/system.log
AuthUserFile /etc/ftpd.passwd
The SystemLog directive sets up logging to /var/log/proftpd/system.log. This is handy when you get errors or want to audit the ftp server you can do it by checking this file.
AuthUserFile sets up the separate password file .
The server should be ok now. We only have to add users. On the shell go to /etc and execute the following commands.
mkdir /home/itkb
ftpasswd –passwd –name=itlk –uid=1002 –home=/home/itkb –shell=/bin/bash
You will be prompted for a password. Once you have done this you created a user itkb who can read files from /home/itkb.
Permalink
06.17.07
Posted in Miscellaneous at 2:52 pm by links
Permalink
Enter your password to view comments
05.30.07
Posted in Linux, RubyOnRails at 8:21 pm by Hedwig Lodrigo
I was trying to delete all rails sessions of a site tonight and I encountered the following error:
Argument list too long.
The workaround is easy:
find . -name 'ruby_sess.*' | xargs rm
Voila, all those files are gone.
Permalink
05.11.07
Posted in windows at 11:28 am by Hedwig Lodrigo
In the command prompt type:
tasklist /svc /fi “imagename eq svchost.exe”
Permalink
03.17.07
Posted in DBA, Microsoft Sql server, TSQL at 1:44 pm by Hedwig Lodrigo
Microsoft SQL Server 2005 provides a dedicated administrator connection (DAC). The DAC allows an administrator to access a running instance of SQL Server Database Engine to troubleshoot problems on the server-even when the server is unresponsive to other client connections. The DAC is available through the sqlcmd utility and
SQL Server Management Studio, only one person can login on it.
By default it only accepts local connections. To change it to accept remote
connections use:
sp_configure ‘remote admin connections’, 1;
GO
RECONFIGURE;
GO
Using a DAC
Open Management studio, and open a new Query connection to admin:instance using a
sys admin account. You cannot use the Object Explorer with DAC. If you just open an
try to connect to the server you end up with this error:
Dedicated administrator connections are not supported. (ObjectExplorer)
You need to open the management console then cancel the connect to server window
and select a new querry and go admin:servername\instance
Here you can execute querries like
select Session_id, login_time, cpu_time, memory_usage, reads, writes, login_name
from sys.dm_exec_sessions WITH (NOLOCK)
Permalink
03.15.07
Posted in DBA, Microsoft Sql server, TSQL at 9:13 pm by Hedwig Lodrigo
–Sample Making a column not null and make it default to a value
–When the table has been in use and the existing values shouldn’t change.
update test1 set code = 0 WHERE code is null;
alter table test1
alter column code tinyint not null;
ALTER TABLE test1 ADD CONSTRAINT DF_test1_code DEFAULT ((0)) FOR code;
–Sample Adding a column with a default value
ALTER TABLE test1
ADD code tinyint not null
CONSTRAINT DF_test1_code DEFAULT ((0));
–Removing a constraint
ALTER TABLE test1
DROP CONSTRAINT DF_test1_code;
–Removing a column
ALTER TABLE test1
DROP column code;
Permalink
« Previous entries · Next entries »