C#

How to quickly add a logging to a coded web test?

A coded web test, as opposed to a basic web test, brings more flexibility to the developer: conditioning, looping, code re-usage, etc. If you haven’t created one yet, you can follow an instruction on MSDN.

Now, because a coded web test can have some logic inside, it makes sense to add logging so that there’s a trace on what’s going …

Summary of Communities to Communities (C2C) 2009 Conference

C2C is a history now. I attended .NET stream and one session on SQL. The conference as a whole was very interesting, well organised, and basically developing. It was a Polish conference so most sessions were conducted in Polish but there were a couple of speakers from abroad too, and they spoke in English.

Basically I’m happy I had a …

MonoRail – RenderMailMessage – System.ArgumentNullException: Value cannot be null. Parameter name: format

This was a nasty issue…

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentNullException: 
Value cannot be null.
Parameter name: format
   at System.String.Format(IFormatProvider provider, String format, Object[] args)
   at System.String.Format(String format, Object arg0, Object arg1)
   --- End of inner exception stack trace ---

Background

This is part of the stack trace I got in one of …

C#, java

Java vs. C#

From now on I’ll be doing much more in Microsoft .NET rather than in Java. Thus, it seems my preparation for SCJP exam will slow down now… Also, I presume there’ll be slightly less about Java on that blog from now on (at least for some time).

I learned about .NET framework and C# programming language at the univesity, but …

Castle.ActiveRecord.Framework.ActiveRecordException: Could not perform Delete for XXX —> NHibernate.Exceptions.GenericADOException: could not delete collection

The beginning of the stack trace I got today looked as below:

2009-05-19 11:01:45,078 ERROR [5232] XXX - Speaker already deleted: Castle.ActiveRecord.Framework.ActiveRecordException: Could not perform Delete for Speaker ---> NHibernate.Exceptions.GenericADOException: could not delete collection: [XXX#XXX][SQL: SQL not available] ---> System.Data.SqlClient.SqlException: Cannot insert the value NULL into column 'SpeakerId', table 'XXX.dbo.lnk_Session_Speaker'; column does not allow nulls. UPDATE fails.
The statement has 
.net, C#

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 …

How to invoke a common coded web test method from GetRequestEnumerator()?

It’s a fact that coded web test methods give more flexibility to the developer, i.e. common code reuse. So let’s create a coded web test in whose GetRequestEnumerator() method you want to call a common method which tests some other requests. Let’s make it look as GetCommonRequests() in the example below:

public class AWebTest : WebTest
{
    private IEnumerator GetCommonRequests()
    

Robust generation of XML documentation comments for C#

Writing comments is something you need to get used to; sooner or later you will understand it’s worth writing comments. Haven’t you find yourself in a sitation where you don’t understand what a couple of lines of YOUR OWN code do? I have…

XML documentation comments are also important, particularly for public members/methods. Even if your project doesn’t require generating …

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 …

System.Net.WebException: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.

One of my applications was supposed to use image having its URL. The Image was instantiated with the stream the server that stored the image file responded with after being requested as below:

// create a request for image
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(IMAGE_URL);
request.Method = "GET";
request.ContentType = "multipart/form-data";
request.UserAgent = "Mozilla/4.0+(compatible;+MSIE+5.01;+Windows+NT+5.0";
request.Proxy.Credentials = CredentialCache.DefaultCredentials;
request.Credentials = CredentialCache.DefaultCredentials;

// get