October 2004 - Posts
Windows Services -- Breeze to develop in C#
Developing Windows Services is no longer a nightmare, thanks to friendly .NET BCLs, beloved VS.NET Intellisense. But during development, due to errors, we might need to manage the SCM database directly like deleting the Windows Service and that too, without having the assembly on hand, which is impossible using InstallUtil.exe.
I have developing a Scheduler Service for our application and this was a hurdle for me. Fortunately, I came across this tool called SC.EXE available from Microsoft itself.
It comes with nice documentation at: http://msdn.microsoft.com/library/en-us/dndllpro/html/msdn_scmslite.asp?frame=true
Somewhere else, I got a nice downloadable Word document also. I would search again and try to update the same too here.
SQLServer and UDFs
UDFs are a cute little things in any database. Just use them in a query and you can loop through the tables and find out without the application bothering about requerying etc.
But in SQLServer, I experienced this glitch. When we created the UDF, it has to be called as owner.functionName unless it is a system defined function.
In our application, we had a generic data access component targetting multiple databases namely three as of now. So this was presenting a piquant situation.
After a deal of small R&D, I found out some of the following workarounds for this:
- Have the application discover the owner and prefix the same. This being similar to a metadata query, will need a roundtrip to the database. May be as an optimization, we can have a Caching other than for the first request.
- After the initial seed data has been run for the database, by the setup scripts, make sure that you also reset all owners to the negotiated user login. You can use the system defined stored procedure
sp_changeobjectowner @objName='GetAppPath', @newowner='lavanya'
It was quite an interesting experience with SQLServer UDFs. But of late, I also came across this URL of having the function behave like System functions:
http://www.winnetmag.com/SQLServer/Articles/ArticleID/15544/pg/2/2.html
DateTime in JavaSCript
Any Webapplication will have a DateTime field. To have the user enter a datetime in specified format and to validate the same is a nightmare. The best way is to give a friendlier UI where the user can pick the Date and Time.
Check out these URLs:
http://www.softcomplex.com/ (Pop Calendar)
http://www.dynarch.com/projects/calendar/ (Inline DHTML Calender)
Date Comparisons in JavaScript
Almost any developer in the worldwide now uses JavaScript widely for its rich clientside validations. And having a datetime field is a common one in any enterprise web application.
Validating a datetime field is again a tricky task for any webdeveloper.
I was searching for some info on DateTime validations and came across the following simple URL:
Check it out: http://www.flws.com.au/showusyourcode/codeLib/code/js_DateDiff.asp?catID=2
It gives the differences in days, hours, minutes and seconds.
Rich Encryption Wrapper for .NET
.NET provides rich support for Encryption in its System.Security.Cryptography namespace.
Of late, I was searching for some info when I came across this XCrypt Component for Encryption in .NET.
Check it out @ http://www.codeproject.com/csharp/XCrypt.asp
It supports almost all Encryption types in .NET and provides an elegant wrapper for the same. It supports both hashing and non-hashing algorithms within it.
Cool Assembly Viewer for .NET
Just browsing for some info and I came across this nice tool. Check out:
http://www.jbrowse.com/products/asmex/
It is quite similar to ILDASM tool that ships with .NET. It also comes with sourcecode. The animation in Help About is also really nice.
For beginners in .NET, the source can be very much useful for learning GDI+ in .NET.