Jul 19, 2010

Site is recycled + ThreadPool.QueueUserWorkItem


Just to let you know that you may experience this issue.

If you have an unhandled exception it may be because of a job queued using ThreadPool.QueueUserWorkItem method.

Actually it appears that although the exception is not affecting the main thread (it was in another one) - the .NET will kill the running process (w3wp in our case).

As far as I read this behavior is implemented since .NET Framework 2.0.
It is because you may miss unhandled exceptions in a child thread (if it's in the main thread the process will be terminated in a windows application).

I imagine each request to a web server as a separate thread so I am kind of worried why unhandled exceptions aren't killing the W3WP process as well.
It only seems to be killed if you create another thread in the request thread and this another child thread exits with unhandled exception.

Will need to investigate a bit more about that.

Jul 14, 2010

Q2 2010 is comming!


Telerik RadControls for Asp.Net Ajax and



Telerik Extensions for ASP.NET MVC are released.


See this post for more information on the cool new things included!


Enjoy!

Thread was being aborted. Exception on Response.Redirect()

This is actually an old issue but I try to make sure I have most of the things that stopped me at some point so I can easilly search.

So if you experience the "Thread was being aborted." exception on Response.Redirect(string Url), it is because this method internally calls Response.End().

In order to prevent it to do so, you will need to use the overloaded version that requires another boolean parameter (something like "bool endResponse", don't remember it exactly).

So the thing that should solve it is:

Response.Redirect("http://donchevp.blogspot.com", false);
This way you should avoid "Thread was being aborted.".

Hope I helped a bit ...

Jul 8, 2010

Go download Telerik Ultimate collection trial!

We have the Ultimate collection uploaded @ telerik.com.
You can reach it by using the green "Download"button at the top of the page.



Included in the bundle you will find:

1. RadControls for ASP.NET AJAX
2. Extensions for ASP.NET MVC
3. RadControls for Silverlight
4. RadControls for WPF
5. RadControls for WinForms
6. Telerik Reporting
7. Telerik OpenAccess ORM
8. JustCode
9. JustMock
10. WebUI Test Studio Dev Edition

Direct link to the page: http://www.telerik.com/download.aspx

Hope you like the new download page.

Jun 18, 2010

How does your manager make a coffee?


I had an architectural problem yesterday.
I was working on a methods and managers I won't disclose but will analogy instead.



Imagine you have a coffee manager. Let's name it CoffeeManager.
In my case not only I had coffee manager but also I had a SugarManager, a CupManager etc.

In order to take a coffee without sugar in a plastic cup I should do something like:

Sugar sugarObject = SugarManager.GetSugar(Sugar.None);
Cup plasticCup = CupManager.GetCup(Cups.PlasticCup);
Coffee shortCoffee = CoffeeManager.GetCoffee(sugarObject, plasticCup);

And this happens at the very frontend of the project (in ascx for example).
And not only it happens that way but the managers are spread in few different projects.

So in the frontend I need to call few different managers, get some results from them and pass those results to the manager that should be doing my job.

I also need to handle all the problems that may rise in the managers so I get a lot of code in the frontend just to get something that in my opinion for that particular case should be returned calling a single method and auto handled in the manager.

I think the front end shouldn't care about business operations that much, also as I said the managers were in different assemblies so I ended up adding few references to the frontend project.

I refactored the code so the CoffeeManager can do this job internally (drawback is that the matrix of all combinations of sugar and cup should be added as a methods in the CofeeManager, but I can live with that).

Jun 7, 2010

Open Access Exception : Please reformulate the query so that the parameter appears on the right side.

You may come up with this exception : Please reformulate the query so that the parameter appears on the right side. in Telerik Open Access

If you have something like:

query = query.Where(x => x.Positive == (positive ? 1 : -1));

The bolded text is an iif expression that the Open Access Linq driver cannot evaluate.

The solution is to use something like:

int iPositive = positive ? 1 : -1
This way the SQL will have the evaluated expression and will know how to deal with it.

NOTE: As far as I know this issue is fixed in the latest releases of Open Access ORM.

Jun 2, 2010

Telerik Open Access exception : The assembly 'xxx' does not have a config file with an openaccess node.

In some old versions of Telerik Open Access you may come to this exception.
I am not quite sure about the latest versions.
However, I've found a forum post that explains that this exception occurs if your project wasn't yet enabled for Open Access.
This wasn't my case so I tried some other things.
At the end, it appeared that "The assembly 'xxx' does not have a config file with an openaccess node" exception may occur if your app.config file is broken. It should be a valid XML file. In my case I have forgotten to close a <class> node with its corresponding </class> ...

Edit: As Yosif Yosifov stated, there is an easier way to check if your app.config file is fine. Simply select Telerik -> Open Access -> Configuration -> Check Settings ... dialog from Visual Studio menu.

May 27, 2010

US courts website runs on sitefinity

Just to inform you that the U.S. courts website was launched by DeepBlue. The site is using our CMS - Sitefinity.

Some more information about the project may be available soon.

Here is the site:

http://www.uscourts.gov/Home.aspx

Hopefully we will see some more .gov sites to be using our precious CMS.

May 20, 2010

Cool MCP business card builder site

I've build a simple business card for me at :
https://www.mcpvirtualbusinesscard.com/VBCServer/b087303c-09bf-4832-9269-83483d5c2d35/profile

You can do this also. It takes 2-3 minutes.

Apr 28, 2010

Nice productivity feature in Visual Studio 2010

I really like this multiline manipulation that comes out of the box with Visual Studio 2010:



I think it will really speed the development. Especially when refactoring old code with lots of lines that need to be manipulated in the same way.

By the way I am sure JustCode team will come out with lots of cool features based on this one ;)

Apr 23, 2010

Sitefinity 4.0 CTP is live!




Kind of late but - check out Sitefinity 4.0 CTP. http://www.sitefinity.com/4.0/asp-net-features.aspx
 
Have a great time playing with it!

Apr 15, 2010

String.Format

Although very convenient for example for making templates and then replace with some values, it may cause tricky problems.

I've reached a code where it was used to add some data to a javascript.
So javascript uses a lot fo curly braces, which are at the same time used for string format to know where to put its values.

There is a way to escape those braces, buy double them, so for example :
function {}
will become
function {{}}

Recently I had the "String was not in a correct format." exception. I tried to debug and found nothing wrong with the string and the values that will be placed.
That was because I was expecting the values to be wrong (null references, something like this) and not the string itself.

Guess what did I discovered after a few minutes of debugging?
It was the string that was corrupted. The problem was that this particullar javascript was in the .ascx file. Someone probably hit the CTRL + K + D so the source was re-formatted, addding some white spaces in between the doubled curly braces.

Be warned that string.Format is kind of fragile when it comes to files that may involve curly braces.

Apr 10, 2010

Nasty shock when handling WCF service exceptions ....

I just wanted to share a recent interesting experience while handling WCF service exceptions.

Here is the case.
Imagine you have to consume a WCF service. You need to handle if the service is gone and do some additional things (let's say you want to display a message).

Let's have an example. Imagine you have the following service:
http://someservice.com/Calculator
This service is used to calculate let's say the interest rate for a loan.
You want to be able to use the service and if the service is not there - you will want to store the borrower data in the db so you can re-submit it ...
What I did in order to test this scenario was to change :

http://someservice.com/Calculator
to
http://someservice.com/CalculatorUnavailable
so I can simulate that the service is gone.
In this case the .NET framework will throw System.ServiceModel.FaultException. It's OK, I handled it and pass it for testing.

After a few days we end up with the service gone again. And the bad news was that it was working on my machine. I needed to simulate it somehow and the problem was obviously some kind of restriction on the server.
Since we wanted to handle such scenarios as well, I wanted to somehow simulate it on my PC.

Finally after about half an hour of debugging I found out the reason.
It was the Server not able to find the domain name record for the service URL.
Then it was easy for me to figure out that if I change the url from :

http://someservice.com/Calculator
to
http://UnavailableSomeService.com/Calculator (note that it matters if you change the TLD (top level domain) or the path. You will have two different exceptions ;).
It appeared that in such cases the exception that .NET will throw is System.ServiceModel.EndpointNotFoundException.

I handled it as well and voilla!

Mar 13, 2010

Meet the first web server in the world! ... and the first release for this year ;)

I was browsing wikipedia to see some physical thinks about CERN and accidently found this image:



According to wikipedia this is the first web server, that sir Tim Berners Lee used in CERN when he invented the HTML to allow physisists to exchange scientific information.

Isn't this exciting?

From that server it started to end up here:


And this is not the end.
This is just the beginning.

How far can we go?
As I said, I think this is just the beginning.
We have the passion to achieve more.
We have the strength to achieve more.
That is why we do achieve more.

Push yourslef to the max,
don't worry about the controls, leave them to us :).

Mar 5, 2010

Telerik OpenAccess ORM Q1 2010 will introduce its DSL Designer, Mapping Details Editor, new Schema Explorer, Update From DB Schema Wizard, Entity D...

A lot of tools I wanted to see live in this product. Finally, from Q1 2010 you can enjoy those really soon!

I will also ;).

Kudos to the team that made it all happen!

Some screenshots from Telerik blog:

The DSL Designer:




Mapping details editor:



Schema Explorer:




Update From Database Model’ Wizard:





Stay tuned ...

Feb 18, 2010

How do you unit test encryption?


I wrote two extenders to be used on the string type.
So you can say "test".Encrypt() and "encrpyptedtest".Decrypt().

I was wondering how to unit test this thing.
The first approach which was really obvious was to encrypt the string and then decrypt it, if you get the string before you do those two actions on it - the encryption is correct.

The question in this approach is : What do you test? do you test the encryption or the decryption?
You can get a false positive result this way. For example if the Encrypt method returns the same string without changing it and the Decrypt method returns the same string without changing it - the test will be passed (the string after encrypt -> decrypt will be the same as it was before).

The other approach is to hardcode encrypted and decrypted string, then pass the decrypted string to the Encrypt() method and see if the result matches the encrypted string.
Then pass the encrypted string to the Decrypt test method and see if it matches the decrypted string.
The question here is "What happens if someone change either the key or the initialization vector for the encryption?".
The test will fail as the strings no longer match (unless you are very very lucky to hit some collision case :), but the methods are valid and they work correctly.

For now - I will use the second method. I will hardcode an encrypted / decrypted pair as well as the key and the IV used for the encryption / decryption.
I will first check if the key and the vector match the one that were used to generate the pair and if they don't - the test will be inconclusive so the guy who changed either the key or the vector can easilly find the problem and resolve it.

Anyway I am really interested in how would you do such a task?

Feb 10, 2010

Some telerriffic T-Shirts

It's time telerik fans to pick up the T-Shirt they like the most.
You can vote for the T-Shirt that you like most here :
Telerik Facebook Page

Here are all the variants you can choose from:



















Now go vote ;)

Feb 9, 2010

One more bar green :)

I am just writing to inform you that I managed to make another bar green, yesterday I successfully passed the "Electronic devices" exam and I have two more exams before I get back to the software world :).

It was obligatory for the exam to write some reports (not quite sure what is the real english word for this) - we had 10 practices during the session. Each one goal was to examine an electronic device (I think 7 analog and 3 digital or something like that).



After we made all the research we had an exam, we had to write a reports for each of the practices we made (you miss one and you can't have an exam, you need to re-work it with other students, which means more days off and more headaches).
I can't be unhappy that I passed it :). I have 4.5 / 6 which is kind of high score (for me, not for the university :).

Anyway now I have the same thing but related to optics, we need to do 10 different experiments, do the reports and pass an exam where they will ask us what did we measured for a random experiment we did, if the answer satisfies the profesors - you pass :). If not - you have another chance to take the exam, you fail on the 2nd chance and you need to re-work all the experiments again :(. So I will do my best in order to pass it from the first time (or in the worst case - from the 2nd :).

I also have some experiments (not exactly experiments) in something that will probably sound like "Probability theory and physical statistics" in english. We will study the probability theory and some statistical laws, then we will be given a set of data and will be asked to perform some actions on it (find the chance for each result to occur, find co-relations between data and so on and so on).

The rules for the exam are the same ;). You have two chances before you go to re-work all the classes.

I really hope I will not look like my idol at the end of this session:




Hopefully I will not write any more posts that are not related to IT but we will see ;).

Wish me luck ...

Feb 4, 2010

Wish me luck :)

I had some really long days. At telerik we are doing some nice but hard to do stuff, I have some university things to do. Some exams to take, some mathematics (Oh, my JustGod :(. My day is about 15-19 hours long (with few short breaks my brain is working all those long hours :).

But I don't write this post to complain. Exactly the opposite - I am writing to share how happy I am to be so busy those days as the bars are getting green, one by one, constantly they are getting green :).

I know I have some amount of tasks to do and I am trying to make all of them green (it is my code for "deliver what was expected", the green bars are "deliver more than expected").

Today for about 40 minutes I did 3 counters at the university - one which was counting up to 5, 1 - that was counting up to 10 (BCD code) and one that was having 10 states but wasn't actually counting :). (3 tasks - yellow :).



Few days ago I managed to fix about 200 comments on the chapter I am writing for the Introduction to C# programming book (seems kind of stable now, should be in CTP state ;).

I actually started this post to inform you about something that happened yesterday :).
This summer (I think it was July or somewhere around July) I was involved in a very interesting project - I was asked by a friend to write a software that will manage a machine.

The machine was having a printer (not simple printer but M600 Advanced printer, it has 4 heads, very hard to work with API and a TCP interface that was blocking the printer if two threads are sending command at the same time).
It was about printing something. So the program should check if the printer heads have enough ink, check some other sensors if everything is OK, and if not - it should stop the machine ...

Nice task that gave me some insight on how the OPC things work (don't ask :).



It appeared that OPC Servers aren't something to easilly deal with.
The main reason - not enough information, some closed standards - the paradise for a developers :)
Anyway we managed to finish most of the things.
Then I got a job at telerik and almost forgot about this adventure :).
Yesterday I heard from that friend and he told me that the machine was at Hannover and that it performed well (means no crushes :).

Now to finish - the nights while I was writing the code for that machine were as long as now. I didn't have time to sleep much. Now I feel happy with the result.
I wonder will I be feeling so happy once again after I manage to finish my sessions at the university ;).

Hopefully yes ;).
Sorry for making you read all this crap :).
Just remember - when you are so tired and is so hard to continue - recall your last victory and the next one will come ...

Jan 24, 2010

Take a time to watch those things. The future is comming ...

I can't hide that I am very excited about what's happening with the technology.
About one year ago (maybe a bit more) I found an open source project called Touchless SDK you can find the post and the video (here).

I played a bit with the SDK back then and managed to do some trivial tasks - move my cursor with fingers, rotate an Open GL 3D globe etc.

I had some great ideas about this, yet I didn't have time to try to implement them.
Yesterday I was browsing to see if there are some TED Talks I haven't already watched and found this one (two parts):

Part 1:


Part 2:



I think that this technology is not yet implemented as it is shown in the video. My guess is that guy has some of it implemented and some of it - not yet. Anyway it seems very promising.

Hope you like it!