Archive | .net RSS feed for this section

Working with Visual Studio on a Mac

15 Aug

When I recently purchased a Macbook Pro, I had a couple of options to set up my .Net development environment on there. I could use a Virtual Machine based solution such as Parallels or VMware Fusion, or run Windows natively using BootCamp. My first preference was to stay inside the Mac OS if possible. I spent some time researching which product other developers are having more success with and Fusion seemed to be  more stable and responsive for the majority of them. I downloaded the trial version from their website and took it for a spin, and have been really happy with it.

I have used both XP and Windows 7 in a VM with Fusion, and the performance has been pretty flawless. I allocate both processors, 40 GB of hard disk space and 2 GB of RAM to a VM. Some of my peers have long been advocating the advantages of developing using VMs, and now I totally get how cool this way of working is. I can create and restore snapshots at any point of time, create a new VM to try out any beta software, and keep my development environment isolated from softwares/utilities that it does not need (avoiding software bloat). I am using a Windows 7 VM right now for the most part and playing around with Visual Studio 2010 on it. I intially found the Unity feature in Fusion (it gives the illusion of running Windows apps natively on the Mac OS)  to be really cool, but I don’t really use it much. I have dedicated a Space to my VMs, and tend to work in full screen mode.

If you end up going the same way as me, I would recommend looking at multiple vendors before purchasing Fusion. I bought if off Amazon, and it cost me $23.49 (including a $10 mail-in rebate). Other sites,including VMware, offer it for upto $80.

Creating MSDN like help using Sandcastle

17 Apr

Just follow these simple steps ( I am using the Ajaxcontroltoolkit library as an example here)

 

1. Download Sandcastle (http://www.codeplex.com/Sandcastle).

2. Download and install Sandcastle Help File Builder (http://www.codeplex.com/Wiki/View.aspx?ProjectName=SHFB).

3. Check http://www.ewoodruff.us/shfbdocs/Index.aspx?topic=html/8c0c97d0-c968-4c15-9fe9-e8f3a443c50a.htm for other requirements. If you have Visual Studio installed, you should probably be good.

4. Run SandcastleBuilderGUI.exe, Create a new project and save it in the same location as your solution file. You can add it to the solution for easier version control maintenance.

5. Add your main assemblies to be documented using the Add button. Make sure your Visual studio project for that assembly is set up to generate xml documentation file (Project->Properties->Build->XML Documentation file should be checked).

6. In Project Properties within Sandcastle Help File Builder

a. Under Build -> Dependencies, Add the folder containing all the referenced assemblies, or add them individually.

b. Select the correct version under Build ->FrameworkVersion.

c. Under Build -> HelpFileFormat, choose the output type (chm and/or website).

d. Under Help File, you can add things like copyright, header, footer, feedback email address etc.

e. Set visibility for different type of members under Visibility.

7. At this point you can build project within Sandcastle Help File Builder to create help file manually. You can see an example of sample output here.

8. To create the help file from the command prompt, use SandcastleBuilderConsole.exe and pass the path to the help project file as a parameter. E.g.

“C:\Program Files\EWSoftware\Sandcastle Help File Builder\sandcastlebuilderconsole.exe” “C:\utils\libs\ajaxcontroltoolkit_help.shfb”.

This can be used in a post-build event to automate the generation of help files.

JavaScriptSerializer – UnDeprecated with .Net 3.5 SP1

8 Dec

Just wanted to mention that JavaScriptSerializer, which was marked as obsolete in .Net 3.5, seems to be restored back to normal status with SP1. Besides checking in the object browser, the only confirmation I found for this was a comment by Scott Gu on this blog post.
This is good news since JavaScriptSerializer does seem simpler to use and can handle anonymous types as well. Its alternative DataContractJsonSerializer is meant more for use with WCF.

Asp.Net Session Timeout control

29 Aug

As web application developers, we depend on the Session to store data pertaining to the user. It’s a common scenario that the user might take a half an hour break to take a phone call or a meal while using the application and come back to find out the site behaving in an unexpected manner because his session would have expired (default value for session timeout is 20 minutes). As a developer, it’s a good practice to check a session variable for null value before using it, but you can create a much more user friendly environment by redirecting the user to a web page indicating that his session has timed out. The best way to do this is by creating a user control that you can just drop on your master or content page as desired.
I looked around for such solutions, and I have described below 2 such good implementations that should cover most scenarios.
Implementation 1
You can create a web control similar to what Peter Bromberg has outlined here.
This control checks for the HttpSessionState’s IsNewSession property and the presence of the ASP.NET_SessionId cookie to determine if the user session has expired. It redirects the user to a timeout page if the session has expired. All you need to do is drop the control on your page and assign the RedirectURL property to your timeout page. The control works for both synchronous and aynchronous postbacks (for those of you using Asp.Net Ajax), and the only downfall for this method is that there’s no way to warn the user that his page is about to timeout.
Implementation 2
If you would like to warn the user before his session actually times out, you can create an Asp.net AJAX friendly control similar to what Travis Collin’s solution.
This control pops up a warning to the user some time before his session times out and gives him a chance to save his session. You can configure the UI of the warning and the time for warning and timeout while using the control. The only thing to watch out for here is that the developer has to make sure the session (and form) timeout value are in sync with the one configured on the control. I faced a small issue in this implementation because it was not recognizing asynchronous postbacks as user activity. To fix this, all i had to do was add a client side handler for page load and reset the timeout there as well.
    initialize : function() 
    {  
        ….
        Sys.Application.add_load(Function.createDelegate(this, this._handlePageLoaded));
        …..
    },
        _handlePageLoaded: function(sender, e)
    {
        this._resetTimeout();
    },

Get free Visual Studio 2008 and .NET Framework Training kit

27 Feb

Get it here.

This kit includes presentations, labs and demos.

Now only if I could find time to go through this :( .

Debugging Dot Net Source Code in VS2008

16 Jan

Its here!! You can now debug the dot net source code in VS 2008. Read more about this in Shawn’s post.
I am still not sure how beneficial this will be in day to day programming, but i guess it will be helpful in troubleshooting sometimes. Especially when it looks like we have found a bug in the framework :) (For the record, i never found a bug in the framework).
-Latish Sehgal


Rss Feed Tweeter button Facebook button