Thursday, October 09, 2008
Exciting new videos
A lot of the posts are from the JAOO conference, which was held here in Denmark not too long ago. And just like last year, I've seen almost all the videos, and found the pretty cool. It seems like a lot of the videos are about programming languages and/or parallelism, and the evolution in those fields - very intriguing!
Maybe JAOO is a conference I should attend next year.
Anyway, check it out at http://channel9.msdn.com
Monday, April 14, 2008
ASP.NET Login isn't persistent
The solution: Generate a static machine key and put it in your web.config.
I found the answer here: http://forums.asp.net/p/947381/1147268.aspx.
See this resource for creating a machine key: http://aspnetresources.com/tools/keycreator.aspx.
Another problem bites the dust!
UPDATE: Well it doesn't seem to be that simple after all. The login still isn't persisten :-(
Sunday, December 30, 2007
How to make the compiler do your work
Before Christmas I spent a few weeks on a school project in computer science. The choice of technology was up to us, and I naturally took the safe path of .NET and C#. I used Visual Studio 2008 as IDE, as it had just come out, and I wanted to try it out. I also wanted to test C# 3.0, which the new IDE of course facilitated. Later I came to think that my team and I wanted to have the solution running on a web server, so the examiners would be able to see the actual prototype working. As I didn't have any options for running the prototype on a .NET 3.5 server, I had no choice but to make the solution .NET 3.0 compatible. This is no big thing in Visual Studio 2008 – you just change the target framework and recompile. Naturally a lot of compiler errors emerged. But to my surprise, they were all related to references to .NET 3.5 specific assemblies, and not my actual code! This got me thinking, and investigating.

What happens when above is built is that the compiler generates the get_Id() and set_Id(int value) methods as before, but then also generates a backing field that reverse engineered looks something like this:

The funny thing is the naming of the generated field. Note the < and > symbols; they are used in order to avoid C# code accessing the field! If I try to get access to the field from a C# method, I will get a compiler error, as < and > are not allowed in the context.
The full property will look like this after being compiled:
I never thought of this, but as all the features of C# 3.0 are "syntactic sugar" changing the target framework while keeping the C# 3.0 compiler, I can have all the features, even though everything is compiled to C# 2.0! Great!
Oh, and by the way: Note the [CompilerGenerated] attribute. I want all of my compiled code to have that!
Friday, September 07, 2007
How did I not see that?
I had a nice experience today. I have been developing a website that uses the native ASP.NET 2.0 provider model. To save time I've just installed the default provider implementations for the MembershipProvider and RoleProvider and am using them.
So now I am in the process of creating an administration-system for the entire website, including the providers, and found myself having an insane bug/error. I had two users in my database, myself and a test person (Hans Hansen). When I updated the users everything was fine, unless I wanted to change the users' roles. If I was editing my own user it worked. If I wanted to edit Hans Hansen, however, the app crashed. The error message was something like: "Cannot update user name ''" (empty user name).
Now, I am pretty sure the user name isn't empty, so I began debugging. After about 2 hours of hopeless looking through code (even the ASP.NET provider stored procedures!), and plenty of theories about the origin of the error (including one or two angry thoughts to Microsoft), I developed a theory. What if the user name was required to be minimum 3 chars? Hans Hansens ("hh") was only two, but my own ("mgj") was three, and for the latter everything worked! Well, I changed "hh" to "hah", and suddenly everything worked! So now I'm thinking, that Microsoft is behind the error, and begin looking quite deeply into their stored procedures looking for the unwanted feature.
After another hour down there, I coincidentally passed the [aspnet_UsersInRoles] table, and lost my jaw. I had finally found the problem. In the aspnet_UsersInRoles table, a previous test user had not been deleted. And he happened to have the same username as Hans Hansen ("hh").
So, in the words of Sting, "I hate to say it, but it's probably me"
Note to self: Make sure test environment isn't corrupted, before pointing fingers!
Monday, April 23, 2007
Something about ID3 tags
The streams I'm reading always seem to be flawed in some way. Well I've found an example where you use the shell32.dll Windows native library to read the tags. I'm looking forward to trying this out to see if it's me thats wrong ;-)
http://www.codeproject.com/csharp/ShellID3TagReader.asp
Sunday, April 15, 2007
Could not load file or assembly
I've started developing a website for a client, and have made some extensions for Umbraco CMS, which I'm using as platform for the whole thing. Then suddenly, while working, my machine crashed totally, leaving me with no choice but to turn it off the bad way – ie. holding down the power button.
When the computer had started again, I tried running the site at 'localhost' again, but got this error message:
Could not load file or assembly 'Blizan.Tools' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
Not knowing how to fix it, I found a few solutions via Google, but they where quite extensive. One forum said I needed to reinstall the entire .NET framework!
But then I had an idea, and it worked: Delete all the files in the "Temporary ASP.NET files" folder (C:\Windows\Microsoft.NET\Framework\%version%\Temporary ASP.NET files\root\)
Now I'm a happy working man :-)
Thursday, November 23, 2006
LINQ to Desktop Search
In this one he talks to Chris McConnel who is the architect for the Windows Desktop Search product. It's really cool to hear his takes on the world, and how LINQ fits into it. And as a new thing in Channel9 the person asking questions is actually not the interviewer but the interviewee (ie. Chris McConnell asks Anders questions). It seems like he's asking all the right things, and we get Anders' views on a lot of different problems in the programming world, for example:
- functional programming
- intentional programming
- LINQ to desktop search
- WinFS
Nice stuf...
Well, here's the link:
http://channel9.msdn.com/ShowPost.aspx?PostID=260202#260202
Thursday, November 16, 2006
C#'ing into the future
I had seen a webast where he talks about C# 3.0 before, and he started the exact same way, by stating that:
Data != Objects
The rest was kinda like that webast, but he seemed to go more into details, which was brilliant. As mentioned I had seen a lot of his stuff before, but there where a few points that, if not supprised me, then made me think. Fx. in my head C# 3.0 == LINQ and nothing more. Anders made it quite clear that that wasn't the case. C# 3.0 is a whole bunch of small things that combined make the developer able to write C# in a query-like syntax. The small features are mainly:
- Extension methods
- Lambda expressions
- Expression Trees
As Anders said, the
var q = from c in Customers
where c.City == "London"
select c.Name
is only "syntactic sugar" translated by the compiler to:
var q = Customers.Where( c => c.City == "London" ).Select( c => c.Name );
ie. method calls! All very simple when it's explained to you like that..
The most important thing, however, was that before we left the lecture Marcus, the technical manager in Composite, got Anders' autograf in the C# 2.0 book :-)
In other news: My G1 school project is finished!! Now I only need the printing part, which I will do tomorrow, so I'm what you could call a free man tonight!! Hmm.. Where did I put that shortcut for Visual Studio ;-)
'Till next time...
Oh yeah, and check this out: http://www.zefrank.com/theshow/gallery/d/8544-1/yeeha.mp3