Monthly Archive for February, 2009

System.IO.IOException: The process cannot access the file used as attachment with MailMessage

Recently I had to improve the mechanism of sending emails so that files can be attached to it. As I used MailMessage it seemed to be an easy task, especially that MSDN provided an example of how to do it. They assumed there that the file used as the attachment was already on the server and it shouldn’t be deleted after the email is sent.

However, I had to upload this file and therefore remove it afterwards. At the end of the day I ended up with an exception thrown while removing the file:

System.IO.IOException: The process cannot access the file 'XXX' because it is being used by another process.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.File.Delete(String path)

Solution

There’s a simple fix for that. After the email is sent but before the uploaded attachment is deleted use Displose() method of MailMessage. This way you will release all resources used by MailMessage.

Alternatively you can create MaillMessage within using block. As a result all resources will be released (disposed or closed) automatically when execution of the block completes.

using(MailMessage email = new MailMessage(...))
{
}

Communities to Communities (C2C) Conference


Get Microsoft Silverlight

There’s going to be an interesting conference in Warsaw on Saturday, March 14th 2009 – Communities to Communities (C2C). I will attend it (already registered). I’m particularly interested in a few sessions devoted to .NET and SQL Server.

Whoever is coming there too, see you there!

Reblog this post [with Zemanta]

Stimator – estimate your website value

It’s all about being popular these days. After a while of having a web site you probably start wondering if anybody is actually interested in it. You can employ Google Analytics to get quite extensive statistics, you can use FeedBurner to track the popularity of you RSS channel, you can check the current page rank of your website. There are plenty of ways of getting some statistics…

Apart from that you can also evaluate the value of your website. It’s not like you feel it’s time to sell it, but why not think that in the age of global crisis you have a back up so that you still have money to buy the food :) Stimator seems to be a nice tool there. Let me cite its authors:

Stimator is a real-time website value estimator. The engine deliveries the most accurate economical value that a website could worth by collecting important data from different sources. The results are indexed to database references and to the financial market in order to re-produce, as real as possible, how much investors are prepared to invest. Stimator is in beta stage as we keep improving this project.

Continue reading ‘Stimator – estimate your website value’

Test your Java experience for free – JavaBlackBelt

Recently I’ve come across another very interesting social service – JavaBlackBelt. Basically it gathers programmers who use Java language and related frameworks and aspects (OO programming, JSP, Struts, JSF, EJB). There are even exams on C#, Ruby, JavaScript, and AJAX but some of them are still beta versions.

Of course I’ve taken a couple of exams and this is my current JavaBlackBelt rank:


You can also have a look at my JavaBlackBelt profile.

It’s a pity I discovered JavaBlackBelt only after passing the Sun Certified Java Programmer (SCJP). However it’s a good practice to refresh Java topics even though I haven’t been using that language in business for a year already…

Reblog this post [with Zemanta]

How to dynamically add new columns to report created with Reporting Services?

Imagine you have a report that displays some data and the number of columns cannot be defined at the design stage, i.e. the number of columns depends on user input. That seems to cause some problems when you want to render this report with Reporting Services…

Solution:

Note: The described solution applies to the case when RDLC files are used by ReportViewer control in local mode. However, it can be simply tweaked so it works in general.

Because the number of columns that should be displayed on the report can be named only at runtime it seems reasonable to update the RDLC file and only then deliver the report. RDLC is an XML file that contains the definition of the report – styling and all fields displayed. So all you need to do is to read the RLDC file into XmlDocument, get some nodes and update them.
Continue reading ‘How to dynamically add new columns to report created with Reporting Services?’

Web Forms Design by Luke Wroblewski

Web Form Design : Filling in the Blanks
Image by Bodum via Flickr

I’m finishing reading a very good book about designing web forms: Web Forms Design by Luke Wroblewski.

Personally I believe it’s a must-read-me book for anyone who is interested in web design, disregarding the fact if they are beginniers or highly experienced geeks. Both can find answers to questions they could ask, compare described examples, see flaws and advantages of existing forms in well known services, and finally choose the solution that fit best the end users.

The book is relatively short but full of suggestions supported with a lot of examples (screen shots). It is dived into several chapters describing individual aspects of web forms, i.e. labels, inputs, actions, help texts, error and success messages.

Highly recommended.

Reblog this post [with Zemanta]



Switch to our mobile site