Okay, I made it work with kind of a hack. (Hope you don't mind). Instead of accessing the hiddenAttribute with a Type index, I just spun through the attribute collection and ripped it out with an "as" since it returns null on mismatched types. I don't like that I have to spin every one of them for each column and I didn't really consider performance problems with trying to cast each attribute, but it's kind of a quick fix. This also lets AutoGenerateColumns work and still be in medium trust. I don't typically use autogenerate, but for anyone else that might be interested, here it is. Hope it helps!
With this, I can successfully bind collections to grids under medium trust. For save to work, I had to comment out the WriteTrace function. (another quick fix until I have time to look at it more).
//AbstractList.cs line 302 in SubSonic project source.
private static PropertyDescriptorCollection GetPropertyDescriptors(Type typeOfObject)
{
PropertyDescriptorCollection typePropertiesCollection = TypeDescriptor.GetProperties(typeOfObject);
ArrayList propertyDescriptorsToUse = new ArrayList();
foreach (PropertyDescriptor property in typePropertiesCollection)
{
//HACK: probably not good but avoids reflective medium trust violations
bool cont = false;
foreach (Attribute attribute in property.Attributes)
{
HiddenForDataBindingAttribute hiddenAttribute = attribute as HiddenForDataBindingAttribute;
if (hiddenAttribute != null && hiddenAttribute.IsHidden)
{
cont = true;
break;
}
}
if (cont)
continue;
propertyDescriptorsToUse.Add(property);
}
return new PropertyDescriptorCollection((PropertyDescriptor[])propertyDescriptorsToUse.ToArray(typeof(PropertyDescriptor)));
}