Archive

Archive for August, 2010

Add STS Reference missing in Visual Studio 2010

August 25, 2010 14 comments

If for some reason, you reset your designer settings or revert to an older version, you will notice that the add STS reference command is no longer available.

To resolve this, all you need to do is

1. Run Visual Studio Command Prompt in administrator mode

2. run the following command

“C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv” /ResetAddin Microsoft.IdentityModel.Tools.VS.VSAddin.FederationAddin

Advertisements
Categories: ASP.NET

ASP.NET 4.0 SMTP throws exception when there is an email attachment over 3MB

August 18, 2010 Leave a comment

If you are encountering the following error

System.Net.Mail.SmtpException: Failure sending mail. —> System.IndexOutOfRangeException: Index was outside the bounds of the array.
at System.Net.Base64Stream.EncodeBytes(Byte[] buffer, Int32 offset, Int32 count, Boolean dontDeferFinalBytes, Boolean shouldAppendSpaceToCRLF)
at System.Net.Base64Stream.Write(Byte[] buffer, Int32 offset, Int32 count)
at System.Net.Mime.MimePart.Send(BaseWriter writer)
at System.Net.Mime.MimeMultiPart.Send(BaseWriter writer)
at System.Net.Mail.Message.Send(BaseWriter writer, Boolean sendEnvelope)
at System.Net.Mail.SmtpClient.Send(MailMessage message)
— End of inner exception stack trace —
at System.Net.Mail.SmtpClient.Send(MailMessage message)

It is because of a bug in .net 4, which does not allow you to upload files larger than 3MB.

They are currently working to put this in a normal service release, but for now a quick fix is available at http://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=30226 which will fix this problem.

Categories: ASP.NET

LinqToSQL and UpdateChecks

August 12, 2010 Leave a comment

By default, LinqToSQL uses pessimistic concurrency when saving the changes to the tables. what this means is that it will check all fields when doing any updates or deletes, this usually goes against what we normally do with normal sql where we just update based on the primary key.

Additionally, this increases the load on the db server as well, since all updates and delete statements needs to go thru this check.

What’s good about this is that it ensures the data is the same as what you had before the update so that it is sure that it is updating the correct data.

So now, what if you do not want this behavior or want to settle for optimistic concurrency? By default each column in all the tables will have the updatecheck property set to always.

You can change it to Never for L2S to not check this column when doing updates/delete.

Alternatively there is a “When changed” which will check only when the field is changed.

Exactly which mode you prefer depends on your business model. But bear in mind that UpdateCheck=Always will increase the load on the db server quite easily especially during high update/delete loads

Categories: Uncategorized