Skip to main content

SafeFileName Property and .Net 2.0 SP1

I built a small utility using C# Dot Net version 2.0 in which I took help of Open File Dialog box windows control to know user selected file path and name. I used “SafeFileName”(Gets a string that only contains the filename for the selected file.) property of OpenFileDialog box to display selected filename on the windows form. I did a fine testing on my development machine and deployed it on production computer. The production computer was up by freshly installed Windows Vista operating system (without SP1 update). since Vista ships with DotNet runtime, my job was as easy as copying my dot net executable assembly and double clicking it. When the OpenFileDialog box tried supplying user selected file name through “SafeFileName” property, it crashed! Damn...!!

The error message was clearly telling me that “method not found: OpenFileDailog.get_SafeFileName()”!! I was darn surprised. Though I did a quick fix for this problem by making use of FileName property (Gets or sets a string containing the full path of the file selected in a file dialog.), with little string manipulation to extract filename from complete file path and got the required result, the unsupported property error on Vista machine continued interrupting my thoughts. I did not see any documentation or remarks giving specific attention to this issue anywhere in Microsoft's official web space. When I installed Dot Net 2.0 SP1 (on production computer) and run my utility (without FileName property fix). This time there is no “method not found” error! The .Net 2.0 SP1 has fix for it though there is no specific note on this in Microsoft’s support knowledge base article
This experience taught me that, Before I go ahead copy my any 2.0 framework based dot net utility and run on any computer, make sure machine has got .Net 2.0 SP1 update or not.


Popular posts from this blog

Windows forgets visual effects settings on log-out or reboot for non-administrator account

Steps given here worked for me with Windows 7 SP1. Hope you may find it useful.

Start -> Run-> cmd (press enter) -> type SystemPropertiesPerformance.exeThis gets you the "System Properties" window, go to  Advanced tab -> Performance Settings -> Visual Effects tab and choose "Adjust for best performance" and click OK. Note: While doing all these UAC doesn't show-up as all changes you are doing will be saved in your logged-in profile account.

Reference material used:

Feel free to comment your findings.

Hangfire with In-Memory Storage (ASP.Net MVC 4/5)

This is in continuation to my previous post: Hangfire with ASP.Net MVC : Simplest Code To Start with.

In this post we will see how Hangfire can be configured without the SQL Server as its backend for job scheduling, instead, manage all in-memory

1) Create ASP.Net MVC 4/5 Projects
2) in web.config file
3) Run Install-Package HangFire -Version 1.6.17 or visit here for latest version:
3) Run Install-Package Hangfire.MemoryStorage -Version 1.5.2 or visit here for latest version
4) I am simply updating a table with a primary key (auto incremented), and string field "StampTime" with current date and time.
5) Open Global.asax.cs and paste below shown code.
6) Run the app and check the database.

using Hangfire; using Hangfire.Common; using Hangfire.MemoryStorage; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using System.Web; using…

Why Akbar was Great?

I have fanatical interest to be acquainted with what made Indian emperors take influential decisions during their reign. Few great kings’ valuable decisions created a remarkable history.

When Akbar accepts the marriage proposal of Hindu King (Bharmal of Amer), he wishes to make an attempt to set an example for two culture and religions and convey the message of peace. Later, destiny takes him to the critical path of life having most depraved political and family oriented problems. Being a true great emperor, Akbar learns and conclude challenges by demonstrating his exceptional leadership qualities. With his verdicts, Akbar stands as an incomparable king of all time. “Jodha Akbar” – brings 16th-century incidents to life and shows beginning part of Akbar’s married life which was, in fact, a deal for political gain. This decision slowly unleashes Akbar’s loving life, internal dreadful politics, painfully desirous people around him and betraying family members.

Jalaluddin Mohammad Akbar is…