Monday, August 30, 2010

.NET FileSystemWatcher and dropping mutiple files

If you spend too much time in the event handler, FileSystemWatcher will miss events. This leads to lost business functionality. There are lot of questions around this topic (how to handle multiple file drops).

Even though you cannot spend too much time in the FileSystemWatcher event handlers, you have to wait until 'at least' file copy is complete (file created event will be fired as soon as the first byte is copied).

I design and develop quite a few server applications which have to be scalable and handle any amount of load. I solved the above mentioned problem as follows.

1. I have created two separate services. 'FileWatcher' and 'FileProcessor'.

FILE PROCESSOR SERVICE
This consists of two logical components. First one writes the full path of the dropped file to a message queue (MSMQ) called 'pre-copy-queue'. Note that there is absolutely no delay here. The other component in this service will pick up one item at time from this queue and waits until it is copied before it makes an entry in queue (MSMQ) called 'FileReadyToBeProcessed'. I am also processing mutiple files in parallel using SmartThreadPool.

FILE PROCESSOR SERVICE
This process picks up items from the queue (MSMQ) 'FileReadyToBeProcessed' and does whatever needs to be done. I am using SmartThreadPool to process multiple items in parallel.

If you are interested in code snippets, let me know.

Monday, July 26, 2010

VS 2010 and Database projects

I run a small company, that means we have to do things the 'smart' way.

I do not think many people are aware of cool things that are available in VS 2010 database projects.

I am so used to using 'refactor' feature in C# projects. Guess what, this feature is available for database projects now. For example, if rename a table, VS 2010 will automatically change all the stored procedures that uses the table.

Moving from .NET 3.5 to .NET 4.0

There are lot of the projects using Membership Providers (for authentication and authorization). The user data (user info, password, roles etc) was created using the code using .NET 3.5.

Recently I wanted to start using .NET 4.0. All of a sudden my users complained about not able to login. When I did the root cause analysis, I found out the default algorithm used for hashing passwords was changed from 'SHA1'.

In order to make things work, I had to explicitly specify 'SHA1'.

Sunday, May 23, 2010

Silverlight - Azure projects and generating proxy

1. Keep 'useRequestHeadersForMetadataAddress' section in your WCF role's web.config

2. Run one instance of VS 2010 with all the roles and start debugging.

3. While that application instance is running, open another instance of VS 2010 and goto your silverlight project, right click on reference to update the proxy references.


This has worked out very great for me. I thought I will share this to other people who are also working on similar projects.

Saturday, May 15, 2010

Installing SharePoint 2010 RTM on windows 7

1. Make a folder called 'SharePointFiles' on your C: drive (C:\SharePointFiles)
2. Copy the contents of your media (CD or DVD) to this folder
3. Open the file C:\SharePointFiles\Files\Setup\Config.config (It is an xml file)
4. Add the following line

Setting Id="AllowWindowsClientInstall" Value="True"

5. Save this file.
6. Run setup.exe

Saturday, May 08, 2010

VS 2010 and Azure local storage utility DSInit

Looks like, by default it is configured to use SQL Server Express. You have to use DSInit utility to let it use your SQL Server 2008 Standard/Enterprise edition.

You will see the following run time error if SQL Server Express is not installed.

Windows Azure Tools: Failed to initialize the Development Storage service. Unable to start Development Storage. Failed to start Development Storage: the SQL Server instance ‘localhost\SQLExpress’ could not be found. Please configure the SQL Server instance for Development Storage using the ‘DSInit’ utility in the Windows Azure SDK.

Tuesday, April 27, 2010

BI SQL Server 2008 and NTILE

BI is all about converting data into 'information' . Even after this effort, you need to filter out noise from information before it is presented to the end user.

For example, every financial BI solution will have some sort of 'Balance' amount. What this means is, this money is owed to you, but not paid yet.

Instead of showing every row in your balance (fact) table, you can categorize the content coming from this row as 'Low', 'Medium' and 'High'. And when higher level people (decision makers) are looking at the information, I will just show the information that belong to 'High' category.

How do I do this at the data access layer?

SQL Server 2008 has NTILE functionality.

SELECT service_date, balance_amount,
CASE NTILE(3) OVER(ORDER BY balance_amount, service_date)
WHEN 1 THEN 'low'
WHEN 2 THEN 'medium'
WHEN 3 THEN 'high'
END AS lvl
FROM fact_balance
ORDER BY balance_amount, service_date;

Saturday, April 24, 2010

TFS 2010 RTM installation and Reporting services Error


When you try to install TFS 2010 RTM, you may get the following error.


You need to edit rsreportserver.config file located at
C:\Program Files\Microsoft SQL Server\MSRS10_50.MSSQLSERVER\Reporting Services\ReportServer and change the value of 'SecureConnectionLevel' to 0 (zero)


VS 2010 RTM and Silverlight 4


I am not sure what is causing this. When I wanted to change silverlight target version from 3 to 4, I was getting the following error:

In order to fix this problem, you need to change registry entry from V3 to V4 at

x86

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\10.0\DesignerPlatforms\Silverlight

x64

HKLM\Software\Wow6432Node\Microsoft\VisualStudio\10.0\DesignerPlatforms\Silverlight



Azure and .NET 4.0

After downloading latest VS 2010, I thought I will make my azure projects to target .NET 4.0
Looks like it is not supported yet.

I see the following compiler error:

Cloud Service projects currently support Roles that run on .NET Framework version 3.5.
Please set the Target Framework property in the project settings for this Role to .NET Framework 3.5

Followers