SubSonic Forums
All Your Database Are Belong To Us

help: cannot run on medium trust web server at godaddy

Latest post 03-26-2008 6:31 PM by Eric Kemp. 24 replies.
  • 07-12-2007 6:09 PM In reply to

    • nlb6665
    • Top 500 Contributor
    • Joined on 07-12-2007
    • Kansas City
    • Posts 5

    Re: help: cannot run on medium trust

    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)));
              }

  • 07-12-2007 6:55 PM In reply to

    Re: help: cannot run on medium trust

    Thanks Nathan... No worries about the hack, the whole hidden columns thing is a hack itself... Based on another thread I was looking at, I'm not even sure that it's actually doing what it's supposed to do anyway...

    Are you using 2.0.3? One of the changes in 2.0.3 was to disable tracing by default for just this reason...
     

    Found a bug? Help us fix it by submitting a Work Item!

  • 07-12-2007 7:35 PM In reply to

    • zhaff
    • Top 500 Contributor
    • Joined on 06-23-2007
    • Posts 7

    Re: help: cannot run on medium trust

    Hi, Eric, just to let you know, your 2.0.3 version working just fine accept for the following Save("Zharfan Mazli") function.. For the time being I will comment out the content of WriteTrace function as per previous reply.

  • 07-13-2007 9:51 AM In reply to

    • nlb6665
    • Top 500 Contributor
    • Joined on 07-12-2007
    • Kansas City
    • Posts 5

    Re: help: cannot run on medium trust

    Yeah I'm using 2.0.3. I'm completely brand new to the API though. Maybe I missed something. Yesterday was the first day I touched it. I might uncomment the trace function and see if it still works. Yesterday I was jumping all over the code to just learn and test it out.

     Excellent work by the way! I was planning on building my own DAL until a buddy told me about this. Saves me tons of work! :) Thank you!
     

  • 07-13-2007 11:31 AM In reply to

    Re: help: cannot run on medium trust

    In 2.0.3 trace is actually disabled by default, so you really shouldn't have to adjust any of the code. It should only present problems if you enable it in the config file...

    Found a bug? Help us fix it by submitting a Work Item!

  • 07-13-2007 12:31 PM In reply to

    • nlb6665
    • Top 500 Contributor
    • Joined on 07-12-2007
    • Kansas City
    • Posts 5

    Re: help: cannot run on medium trust

     Cool. I'll do that instead. Much cleaner!

  • 07-17-2007 1:48 PM In reply to

    Re: help: cannot run on medium trust

    By the way, I don't the default behavior is working yet.  I had the same error as Zhaff in a medium trust environment with SubSonic 2.0.3 "out of the box" and even when I specified enableTrace=false for the provider.  I had to comment out Utility.WriteTrace() to get it to work.

  • 07-17-2007 2:03 PM In reply to

    Re: help: cannot run on medium trust

    One point of clarification... enableTrace is actually a SubSonicService level setting, at the same level as defaultProvider and templateDirectory. I screwed up the release notes... Sad

    This is interesting though... Apparently, while the value check in WriteTrace should be enough to prevent the objectionable code from executing, just being present is enough to cause the problem... We're going to need to revisit how we approach this issue in the future...

    Found a bug? Help us fix it by submitting a Work Item!

  • 03-25-2008 1:55 AM In reply to

    • lfoust
    • Not Ranked
    • Joined on 03-25-2008
    • Posts 1

    Re: help: cannot run on medium trust

    Has this issue been addressed yet? I am using SubSonic 2.1 Beta 2 and I am getting the medium trust error when trying to call the save method of one of my entities. I have tried putting the enableTrace="false" in the providers section of my config file and that didn't fix it.

    I also tried commenting out the Utility.WriteTrace method body and recompiling and this did fix the problem. But this is a just a workaround. Anything else I should try?

     Thanks.

    Filed under:
  • 03-26-2008 6:31 PM In reply to

    Re: help: cannot run on medium trust

    This was fixed just after the beta 2 release, and is reflected in SVN revs 353 and later...

    Found a bug? Help us fix it by submitting a Work Item!

Page 2 of 2 (25 items) < Previous 1 2 | RSS