I figure this one out. What helped was getting more information than the generic error message. This link give me the information that allows MOSS to show more of an ASP.NET error. http://blog.thekid.me.uk/2007/02/15/a-solution-to-an-unexpected-error-has-occurred-in-wss-v3/
The problem turned out to be that my class was not marked as public.
Maybe others will learn from my mistake.