Sunday, February 19, 2006

Chronicles of DotNetNuke:Krish, .NET 2.0 and DNN

I was just wondering how much DotNetNuke is getting popular. At RAC, I often see atleast one major DNN project every week. By major i mean it would definitely take a week or more to complete. Hey wait! What is DNN?

Well DotNetNuke is a community effort - a CMS that could be used as internet and intranet web applications. Written entirely in asp.net, it is as good as any other CMS. PhP is widely used for CMS and there are excellent such CMS in the form of phpBB, vBulletin.

Well one thing that unlike most think, CMS is not all about Forums, but it is much more. Take a look at PhpNuke based portals you can see how powerful they are. For us what interests more is that a well accepted CMS generates a lot of jobs, be it part time or full time. Like I happened to notice quite a few custom module development projects for DNN. So isnt it good?

That is the reason, i wanted to learn something about DotNetNuke, if possible contribute all i can to the Microsoft Open Source Community. If i can get atleast 10% out of DNN by end of March, then i would consider myself efficient. Trust me, there is going to be a lot of future and opportunities for those who are well versed with DNN. It has become so much popular in just an year and half(when i first learnt asp.net, Dnn wasnt that popular) There are jobs, especially my fellow guys/gals who wish to pursue MS abroad - you should learn DNN if you are well versed with ASP.NET

These days Video Based training has become so much popular. Even DNN has good training videos available, at their website, heres the link.
Documentation: http://keihanna.dl.sourceforge.net/sourceforge/dnn/DotNetNuke_4.0.2_Docs.zip
Training videos at :
http://www.dotnetnuke.com/About/TrainingVideos/tabid/810/Default.aspx

Believe me guys, I am not wrong most of the time especially in catching things useful for career. First when i opted to learn .NET most of the people laughed thinking its not such a good idea, but today it has given me part time job and lots of satisfaction. So those who are familiar with .NET and vb.net language, you better lay your hands on DNN. join hands with me - we can learn things together.

Saturday, February 18, 2006

Tribute: John Vlissides

Recently, i came across this thread on DevSourcel through which i came to know about the demise of Mr.John Vlissides. Well not many of us know him, but the core of software developers, the most professionals guys out here definitely knows him as one of the "Gang of Four".
Heard of Design Patterns? If so then, you should know this person. Mr. Vlissides is one of the four persons at IBM who gave the world the notion of Design Patterns and more importantly the key person behind the launch of Project Eclipse. He expired after a 19 day illness due to brain cancer. Without his effort on design patterns and project Eclipse, the world of software would not have been what it is now. So please pray for him.

Hide and Seek : WebServer utility

I just found this cool article on still cool utility that comes along with .NET 2.0 SDK; Using this utility, the article says, one doesnt need IIS to run their applications. As in the previous entry; i earlier has lot of problems setting up IIS for Asp.net and this is something cool. This is really cool for beginners too - beleive me banging your head with IIS is very tough than using this utility. There are some limitations but it ll not matter for newbies. So go ahead read that article.

And you know how i found out that one? through ads on my blog :D; i am not trying to sell my blog - but that is the truth. i was clicking on the ads myself and in turn visited to devsource - made a few searches over there and got this one !! So click ads and learn something :))
By the way link for the article
http://www.devsource.com/article2/0,1895,1886246,00.asp

Friday, February 17, 2006

Haunted Mansion : ASP.NET and SQL Server Express

If there is no other technology as good as the .net platform, then there is no other technology with as many vague-properly undocumented issues as the Asp.net platform. There are several server side issues both during development and deployment. Long ago, when i first started asp.net programming it was hell for me, to set up IIS working because even if you have a single virus active ASP.NET applications refused to run. And more over with Visual Studio 2003, unless IIS is working properly you cannot imagine programming Asp.net applications.

With .NET 2.0 and Visual Studio 2005, i thought the issues are all over, i guess i saw somewhere that you dont need IIS to develop Web Applications(ofcourse to run and test them you do need IIS) Then i thought i could give IIS, a finger - because it has really irritated me so much. As it is I hate web programming and with IIS, my hatred grew. But future is all about ASP.NET and Web Services, even if you arent in love with them, you have to marry both.

Real nuisance i would say are the Xml configuration files. I agree they are really nice feature, but i would say from developer perspective they are nuisance. When Microsoft lovers are more inclined towards GUI way of programming, with Visual Tools workin with stupid XML files is really painful. You talk about security, you see web.config or machine.config; that is really stupid. There is a reason for me to get irritated so much. Recently I was working on C#-Vb.NET conversion project. It involves SQL Server Express 2005. Yeah fine, i had it installed and wanted to test it with asp.net application. But the connection refuses to open when running the program it says:
Login failed for the account Archsoft\ASPNEt
(Archsoft is my machine name)
I have been banging my head since two days, trying to figure out what is to be done. But nah!!, i dont get any feasible solution.

I thought of installing the SQL Server Express Management Studio, which is ofcourse free(30mb download, i wonder why it isnt included with SQL Server Express) But my drive where sql server epxress is installed is only 4000mb of size and i am left with only 30mb of free space.(it needs 191 mb of free space)

Now i googled out for one last time, before i give up and found this link.
http://forums.asp.net/1176822/ShowPost.aspx

Anyway the worst part of this is that, the issues are very new compared to what we had in .NET 1.1(they were age old with quite a few solutions online) . And you know what !!! Check out MSDN support's answer for that issue, here :
http://support.microsoft.com/default.aspx?scid=kb;en-us;316989
It says


To resolve this issue, use one of the following methods:
Method 1. Programmatically change the security context of the ASP.NET worker process to a user who has the correct SQL Server permissions.
Method 2. Change the default configuration of ASP.NET so that the ASP.NET worker process starts and runs under the context of a user who has the correct permissions in SQL Server.
Method 3. Grant the correct permissions on SQL Server so that the aspnet_wp account (or NetworkService account, for an application that runs on IIS 6.0) has the appropriate access to the required resources.



Come on!! The exception i get during developmet clearly says
Login failed for user 'MachineName\ASPNET
Any dumbass with common sense knows that the account ASPNET doesnt have sufficient privileges. So one expects the support article to answer "how to set aspnet the required privileges?" But as you can notice above they gave 3 methods on how to resolve this problem and all are statements !! Is that any kind of support??? Well if it is then i m a dumbass then.

Very soon i shall figure out the solution and i shall provide the support what the article doesnt. Till then join me and abuse that article :))

See you soon with solution.

Freedom of Expression in .NET with Express Editions

Well Microsoft has realized that the apart from being an excellent platform, the major reason for the success of Java is that it is community friendly - most of the Java stuff is free for developers and thus attracts huge newbies. There was one thing which Microsoft always boasted about - its IDE - THE VISUAL STUDIO. Inspite of being very expensive, it has become so powerful that everyone was willing to buy.(ofcourse those who are loyal to ms)

With advent of Eclipse, things changed a bit more than what one has expected. Earlier the IDE market for Java was ruled by Borland whose Delphi is also very popular amongst Windows Developers. But again Borland Studio wasnt free(there is a free developer version,limited). Eclipse is the best IDE for Java, but what i feel is that it really needs a high end machine( my machine is 733Mhz P-III with 256MB SD RAM and I run .NET Studio successfully, but it always makes me dull when i run Eclipse - somehow i might be doing somehting wrong) Anyway that is a different story, but Eclipse is a bigggggggg hit. There are thousands of plugins for Eclipse, which can all be used to extend the IDE to unimaginable extent. NetBeans is also getting popular, with its free community edition being released. Anyway this is not a Java blog, so let me get back to the topic.

Microsoft has taken a whole new strategy to get a fair share of developer market through its .NET 2.0. Apart from being the best release by Microsoft so far, another cool offer from Microsoft is their Express Editions. There has been a lot of publicity and encouragement from Microsoft for developers to try their Express Editions. Well, just for information for any IDE, there are usually numerous versions - Professional. Enterprise, Express,etc. Express Editions are free for download and there are three Express Editions as of now. Visual Basic Express Edition, Visual C# Express Edition and SQL Server 2005 Express Edition. All of these are free for download, for almost another 10 months. They have almost all the features that a normal developer needs or uses in Visual Studio 2005. Some of the advanced features might be missing, but frankly inspite of using Visual Studio .NET since two years almost everyday, I feel i dont even use 5% of the features .NET provides. The major use for an IDE atleast for a normal developer like me is Intellisense and Debugging. Very soon, i shall add an article about Debugging, and how it makes developers life very easy to make their applications error-free.

Anyway for those who wish to try .NET and are scared to get VS 2005, can just download the express editions and get most of the .NET features at your place; then try out. They are each somewhere near 400-500 mb.

Well before i end just let me tell you, that from tomorrow, i shall a daily funda to my blog. The funda would have few curious questions about .NET/C#/Vb.NET and answers to them. And hey, as you have already visited my blog, just click over the Ad that is placed on the top of this page- that fetches me some money dude!!

Thursday, February 16, 2006

Asynchronous Programming - Delegates : Always a problem for 90% of .NET developers

Most of us when working with GUI applications has definitely encountered certain problems with updated refresh of view. I mean to say that if you perform a task which takes atleast 10 seconds odd to finish, and then you try to switch between windows and attempt to get back to the main application window, you can notice that the application has freezed. You have numerous options to overcome this. the simplest one is write a void method/sub procedure and create a thread that executes that sub procedure. Inside the sub procedure, you can call the Refresh() or Update() method of the form you wish to refresh the view. Well this topic is not about how to use threads to make Windows applicaitons free of freezing effects, but is about asynchronous programming.

Asynchronous method call is where we call the method and proceed to execute the next line after the call. We do not wait for the method to return. So how will you know when your method has finished execution? what if you want to return some information or a value once the method has been computed? As an answer to all these questions, there is the CALL BACK function. The call back function is that function that is executed when the method that has been invoked asynchronously has returned(completed execution) The call back function is passed as a delegate and so is the function that is being called. So learning how delegates work is the first step for one who wish to use asynchronous calls to functions. Almost all tasks which takes considerably good amount of time to execute have asynchronous versions, already provided. For example on a stream you have a BeginRead() method. All the methods that are asynchronous starts with "Begin" and has a corresponding "End" method which is actually a call back method.

First of all. Let us look at working with delegates in simple terms. I am no expert and this is no documentation. So spare me if you dont understand and go join some coaching classes.

Basic Signature
public delegate [returntype] [function-name] ([parameters]) //C# version
public delegate
[function-name] ([parameters]) as [returntype] ' Vb.NET version

For example
public delegate int MathOperation(int a,int b);

We have declared a delegate. delegates could be treated as objects, just that they can call only one method. Just follow the steps you shall understand.

Step 1
1. Declare a delegate, usually outside the class as shown
public delegate int MathOperation(int a,int b);
2. You need to prepare a method same as the delegate signature. For example, for MathOperation a valid method would be as
public int Addition(int a, int b)
{
return a+b;
}
3. You need to then create an instance of delegate passing the method name that it is supposed to call. Here,
public static void Main(string[] args)
{
//create an instance of delegate
MathOperation add=new MathOperation(Addition);
Console.WriteLine(add(10,20));
}
As you can see you invoke the method through delegate instance as shown [ add(10,20) ] It appears as if we have given a new name to the method instead of using the exisiting name. So what is the use of delegates when i could do the same without using delegates.

Usage??
The need for delegates rises in the situtaion where there are two objects say obj1 and obj2. Obj1 has a reference to obj2, so obj1 can invoke any method on the obj2b, but what if obj2 needs to invoke a method of obj1 whose reference it doesnt have. In that situation obj2 would provide a method to which obj1 can pass a delegate which holds the reference to the method of obj1 which obj2 needs to invoke. Inside the method of obj2, the delegate is registered with the obj2, so it is not the object reference that obj1 has but direct link to method of obj1. I hope you understand this. If you dont, then read again :))

[to be continued .....
[Next ... how to perform asynchronous method calls?]

Wednesday, February 15, 2006

Code Central

Just wanted to say more - if any of you guys need some kind of help in resolving bugs for your .NET projects, feel free to contact me at krishnabhargav@yahoo.com; you need any code snippets, just ask over here. I really have a lot of code with me, and I am ready to share with you all. But hey, dont demand - i am an head strong egotist. So better, request and leave. I shall definitely answer any question within my reach. That one thing i can promise.

Beauty and Beast - Advanced Serialization

Serialization is a technique in which an object is coverted into a form that could be streamed over any Stream - this includes a FileStream and HttpWebRequest 's RequestStream etc I intentionally mentioned Request stream here. Everybody who has programmed for an year or so, uses Serialization on FileStream to save their objects, but recently i could use it differently. My requirement was that - I want to send an "object" from a windows applciation to a Remote ASPX application. I thought of Remoting the server on IIS, but it involves a new learning cycle for me as i have never worked on deploying remote objects on IIS. So this is the technique i could come up with. I opened a http request on the aspx page which accepts the object that i am going to send. On the request, i could get the request stream say "rs", then i serialized my object on the response stream using BinaryFormatter. That is it. But the serialized data to be streamed, you should also fetch the response, only when you call the GetResponse() your data would be actually streamed.

In the aspx page, i created another BinaryFormatter in the Page Preload event handler. There i fetched the request object and the base stream inside it, Then i called the Deserialized over it to get back my object.

This was really cool way to establish communication between a windows application and web application. If it was XML serialization , then probably i could even communicate with a servlet or a JSP container. I did not try it out yet, but if anyone does that, post a comment over this blog.

I had another requirement where I used serialization again, but here the requirement was that the object had some not so secret, but information that my client wanted to secure. So i thought of encrypted serialzation and i have found a good article whose link i posted it over here. But somehow i could not implement it successfully. Then i thought if data is compressed, it is not human readable in any text reader like notepad or wordpad. So i thought of using the compressed serialization as in the link i gave. But GZipCompression did not work for me and i had to go for DeflateCompression method. I created a compression stream over the filestream and i used it for serialization. The important point is htat deserialization shall not work unless you add the Flush() statment after the serialization is performed. I shall add the code block, in the next blog.

The applicaitons of Serialization is not well covered anywhere in the documentation. It could be well used, and its so beautiful. But hey! there are numerous issues you shall face during deserialization. As i get more acquainted with blogging, i shall make this blog a better and excellent place for information on .NET and sometimes Java. I love bill Gates, just because he gave us .NET platform.(ofcourse i would have loved Jennifer Lopez, had her company come up with something as good as .NET)

Monday, February 13, 2006

A Valentine's day serialization

Recently, I have worked on almost three projects involving only serilization. I mean pure serialization. Right now i have a work to do, so I just want to save a link on my blog.
This is an excellent article on Serialization and how one can create an advanced Binary Serializer.
Also shows how to perform encrypted Serialization,Compression,etc.

http://www.marcclifton.com/Articles/Performance/RawSerializer/tabid/130/Default.aspx

I can also show you real world use of serialization when i talk about it later. Also i would show how to perform FTP UPload/Download in .NET( my latest project is that) using two different ways - using WebClient and other using FtpWebRequest/Response(.NEt 2.0 only)


For now that is it.

Tuesday, February 07, 2006

Pain with DHCP

having searched online for all possible ways to know if the DHCP is enabled on a system, i could finally get hold some WMI way to do so. Thanks to aspfree, i did not go through it yet but woud do so very soon. Anyway heres the code:

Try
Dim searcher As New ManagementObjectSearcher( _
"root\CIMV2", _
"SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
Dim dt As DataTable = globals.getNetworkInfoStructure
For Each queryObj As ManagementObject In searcher.Get()
Dim IPAddress As String = ""
If queryObj("IPAddress") Is Nothing Then
IPAddress = queryObj("IPAddress")
Else
Dim arrIPAddress As String()
arrIPAddress = queryObj("IPAddress")
For Each arrValue As String In arrIPAddress
IPAddress &= arrValue
Next
End If
globals.addNetworkInfo(dt, queryObj("Caption"), queryObj("Description"), queryObj("DHCPEnabled"), queryObj("DHCPServer"), queryObj("DNSDomain"), queryObj("DNSHostName"), IPAddress)

Next
Me.DataGrid1.DataSource = dt

Catch err As ManagementException
MessageBox.Show("An error occurred while querying for WMI data: " & err.Message)
End Try

This is ofcourse only a part of the code and i shall update it very soon, once i modify it as per my need.
Anyway heres another new thing i learnt in .NET SDK.
You have this mgmtclassgen tool which you should run from visual studio commmadn prompt and generate a vb or C# or any other .net class which functions exactly like the WMI object, just that you need not use any managementobjectsearcher. More information on it later. Meanwhile just google out for "mgmtclassgen" and you ll get the information needed.
Thats it for now.

Sunday, February 05, 2006

Me, .NET and FxCOP

Well its been long since i posted my first blog, probably about how to approach BeanShell and PMD. Well to add another fact , i received a complimentary copy of PMD Applied and guys this book is really cool and one cannot ask for a better and simple book. PMD is an open source tool to test Java code for consistency and coding standards based on some pre defined rules. We have a similar tool for .NET Platform called the FXCop which i have just downloaded. I have to try out yet and i shall try it out on my final year project. Its high time i start my project and i hope to finish it at the earliest.

Coming to FXCop, it has a cool but outdated GUI look(i checked out 1.32) it appears like some old good tools - anyway the functionality is what matters more. I wish it has some project import option and can check the entire project of VS.NET 2003 Studio. For those who doesnt know how to go about with FxCop, you just need to create a nw project in FxCop and add your assemblies to the to the project. Assemblies is a cool term and it really makes me feel wow when i last heard about its definition. Well i dont want to recall that and type that over here but simply put - an assembly is a building block on .NET applications.(well its not the definition, atleast for you all).
Once you add the assemblies, you can use the tree explorer to your left to check out the rules.

Just for your information, based on the documentation of FxCop - it uses MSIL Decompilation, and other such ways to test if the rules are applied. PMD works a bit different over here. It is a static code testing tool, it doesnt use any memory profiler, just raw interpretation of Java Code in its original form. I havent tested it out yet of bulkier code, will test it out soon.

I am now going to test the rules against my assemblies and i am using only the Remote Machine part of my project(there is another administrator part) If everything goes well i shall add this information in my project report on how my application has passed the FxCop Test. When we are ready to test, we just need to click the "Analyze" button on the top, with a play icon. It really performs quickly - i expected something around 5 mins for some code :) Hey wait , i have deleted one assembly from the Project and it raised an exception. :-? Not well debugged. Well this is usually the case with excellent community products. I hope it has been rectified in the .NET 2.0 Version. I shall check that out very soon. Well let me start the tool again and check this time for rule violations in my code only. This time i shall let you know even the time it takes to verify the assemblies. Well it takes only matter of 5 to 6 seconds, but what is irritating is that it is giving some information about the violations in the code which you havent written. So what i did is that i have unchecked all the rules in the rules tab and then i have checked only the "Performance Rules" and you can really expand the performance rules and check only that are applicable and which makes sense. I would like to test if my application performs well, i am least bothered about auto generated code- i cannot change it can i? There is a rule "Mark Method as static if "this" or "ME" is not used inside the method" well, what if it accesses the members of the same class to which its currently member of? So the rules doesnt appeal as much to me. So i uncheck that rule for a while, because when designing my application i have made sure that the methods are made static wherever necessary, but my app deals with Remoting and Static Methods in Remoting are big pain, instead i already use Singleton objects. Am i correct here?

The cool aspect of using such features is that we get to know the performance issues and we should really read the ruleset properly and it improves our coding techniques. Let me explain. When i tested my code with FxCop for only Performance and i have unchecked "mark methods as static", there is one rule violation that has caught my eye. It says "Test for empty strings using string length" Seeing that i clicked on the rule violation info displayed and to the bottom i can see the description - the bad part is that the description is in IL :)) Well i normally test for empty string using Equals() method this way:
If string1.Equals("")
return
End if

There is clearly performance problem which i havent noticed till now - We create an empty string object, call a function, so there is lots of process being performed at the back. Instead I could have done it with simple string1.Length property as
If string1.Length=0
return
End if

There is no creation of new object, no stack operations are performed and this definitely improves the code performance. Good! I learnt a new thing which i shall keep in my in the near future. This is why i said such tools and their rulesets are always interesting.

One thing with FxCop is that it tests for autogenerated code, i guess. And it annoys me. I wish there is a way where it tests only for my code. I shall have to check out the options.
At this point i would also like to tell about "Channels" in Remoting. Having played with .NET Remoting for my application, which involves sending image across the channel. I have discovered two things:
1. Images cannot be sent directly like other objects. Instead, create a Stream object and save your image in the stream and send the stream instead. Later you can use Image.FromHStream method to extract the Image.
2. There is helluva difference between the performance of HttpChannel and TcpChannel. When i used a HttpChannel to send the image capsuled in a stream object, it took reasonable amount of time. Later i replaced HttpChannel with a TcpChannel and it has improved the performance significantly.

My project requirement also includes "communication over encrypted and compressed channel". I have no clue as of now, how to implement such a channel of communication in my application. But just for a feature i have mentioned it and i can remove it anytime, once i see a performance degradation cos of those features. Atleast i have a reasonable answer if question is raised.

There is a lot of scope for one to research in .NET Remoting and i am worried before i learn something in Remoting, it would be replaced soon by WCF(I think its for distributed computing) I have had my friend download the latest Windows Vista SDK. Got to check that out very soon. .NET is fun and Microsoft software development tools are better than any other tools in the market. That is for sure. ( i am not a java antagonist, just that i love .net more, cos it makes me feel wanted :)) )

RAC Life is not as smooth as it was earlier. I just took up a C# to Vb.NET Converssion project and it removed the hell out of me. Well it was really fun and i really learnt some cool things which i wasnt aware earlier. Well that is all the work i had at RAC, though it appears pending projects are "4", 3 of them i have reported work complete. There are some good buyers out here at RAC and i really enjoy working for them. Ezra, Levent(my java tips boss) and now Uwe are now the most cool guys i met at RAC. Special thansk to Uwe who gave me an extended deadline for C# to VB Conversion project. Anyway always thankful to one person on this earth without whom my life would have been differently painful.

Just for those who wish to try out software development on Linux, you can get hold of different Linux LiveCD which doesnt need any installation to be done. You have good set of cds and heres the list.
http://www.frozentech.com/content/livecd.php?pick=All&showonly=development
Recently i downloaded Monoppix to try out Mono.NET on Linux platform and later i shall download Pollix for Java Development. Mono-Live i heard is cool, but it was 700 mb odd n i wanted to download as early as possible so decided to go for Monioppix which is 470mb odd.

Well guys, see you soon again with .NET fundas.

Krish

Saturday, December 17, 2005

Welcome

Hi all,
This is Krish, from India. This is my attempt towards maintaining a blog. Basically i am very busy person(lazy!!) and i am not sure how long am i going to maintain this blog.
well let me tell you that i am kind of crazy person and i am going to post only Technical, Programming and my work related stuff over here. Those who are interested can visit my blog for regular information about my search, my research and my re-research :))
well for now, let me use some shorthand notation - i am in the process of making a tutorial on Jaa Scripting Languages and as the first part i would start with BeanShell, a very easy scripting language that could run on the Java Platform. Well you are not going to read this article here, and i wish you would all have some time to visit www.java-tips.org and that is where i am currently working for. You can read my book-reviews and my tutorials from now on at www.java-tips.org. The book reviews have already been posted and very soon you shall get to read a complete tutorial on BeanShell and other scripting languages.
Well For now, that is it. See you very soon.
Well the shorthand notation begins.
BeanShell
1. Download
http://www.beanshell.org/bsh-2.0b4.jar
2. Start the app and use the print command.
3. What are the commands available on the Bean Shell?
4. What are the advantages of using BeanShell?
5. any reader when he reads an article about something really new, he would first like to know
1. Purpose of why to study this.
2. He searches for something really exciting but advanced . yeah that is the nature of the readers. They want to do complex things but learn how to do in a simple way. So i should concentrate on doing exciting things with BeanShell.
3. What all he can do with BeanShell?
This is crucial. I am going to take up each and everything that one can do with beanshell and provide one simple example for it and infact explain the basics behind it.

Remember that i shuld not provide extreme examples , you already have them on the www.beanshell.org website, all you need to do is to put all the information in the manual in a single but superb article. This should be your basic goal.

I just donwloaded the Manual for BSH from the website and its some 96 Pages. so i gotta invest 106 to get the manual printed and spiral bounded. Once i get the manual i shud work on it.
So i should spend the next two days working on the Manual and collecting important notes.
Now i gotta prepare powerpoint slides for the best person in the world ;) I also need to report TOEFL and GRE SCores through FAX #:-s thats a tedious job man.
Krish