Full/Medium Trust

Oct 7, 2011 at 2:25 PM

I've had difficulty deploying IndexTankDotNet to some shared hosting servers (namely - Godaddy).

due to the attribute of an overidden member:

      [SecurityCritical]
      public override void GetObjectData(SerializationInfo info, StreamingContext context)
      {
         base.GetObjectData(info, context);

         info.AddValue("httpStatusCode", httpStatusCode);
      }

 

Can anyone confirm if IndexTankDotNet requires Medium or Full Trust?

Is this circumventable?

Many thanks,

Shaun.

Coordinator
Oct 7, 2011 at 2:33 PM

I'll have to look into this.

First, I need to know a couple of things.

1. Where did you get this code snippet? There is no such "SecurityCritical" attribute in the source code. The override exists only to ensure that IndexTankExceptions can be serialized.

http://indextankdotnet.codeplex.com/SourceControl/changeset/view/ee35406d7b85#IndexTankDotNet%2fIndexTankException.cs

2. Have you tried this on any other shared hosts besides GoDaddy? And if so, are you seeing the same behavior on those hosts?

Oct 7, 2011 at 2:59 PM

Sorry, I tacked on the [SecurityCritical] attribute as a suggested solution.

Ok so I have the same website in 2 different hosts, 1 medium trust and 1 not (I've disabled custom errors for a few)

Godaddy host:

http://cpdlectures.com/testIndexTank.aspx

Medium Trust host:

http://dev.shaunus.com/testIndexTank.aspx

Coordinator
Oct 7, 2011 at 3:12 PM

There is nothing to my knowledge in IndexTankDotNet that should require Full Trust.

The Medium Trust search box (shaunus.com) seems to work ok. Which host is are you using for that?

Oct 7, 2011 at 3:29 PM

Is there anything that requires Medium Trust?

The Medium Trust server is with SoftSys hosting. ($25 per year, 1GB space - boo!, Medium Trust - yay!)

The Godaddy Server doesn't have this and doesn't work.

It has to be something within IndexTankDotNet, it seems to be the method I outlined earlier.

Coordinator
Oct 7, 2011 at 3:29 PM

The latest source code check-in has this attribute in place now.

http://indextankdotnet.codeplex.com/SourceControl/changeset/changes/b6caee36a6c2

Could you please download this source version, compile, and give it a try? Let me know if it solves the GoDaddy issue. If it does, I will update the NuGet package with this fix.

Coordinator
Oct 7, 2011 at 3:32 PM

Are you saying the GoDaddy account doesn't grant medium trust? Wow, that would be surprising, even for them.

Oct 7, 2011 at 3:35 PM
Edited Oct 7, 2011 at 3:44 PM

That's correct,

With Godaddy Shared hosting you do not have Medium Trust permissions. (you  cannot get it without renting a VPS either)

I take it IndexTankDotNet needs medium trust? Am I able to circumvent this?

 

(The attribute from what I gather should be added for .NET 4 but didn't fix my Godaddy problem anyway)

Coordinator
Oct 7, 2011 at 3:43 PM

So, you are saying this latest check-in did not fix the GoDaddy problem?

And out of curiosity, are you by any chance serializing these exceptions in your code?

Coordinator
Oct 7, 2011 at 3:51 PM

Hmmm... poking around using Reflector, I see that the way Exception is serialized has been changed in .NET 4. I think I can figure out some kind of a workaround though. Unfortunately, I don't have access to a GoDaddy account to test this on, so I will ask you to give it a try for me again. Stand by... ;)

Oct 7, 2011 at 4:28 PM

Thanks LDumond, This is some exceptionally good service ;)

I have medium trust myself (Shaunus), but my client CPD doesn't. I've had problems with Godaddy and these sort of permission issues before.

I've been messing around with the source myself and had already added in the attribute and several like it (that's what's on the server now), so yeah, didn't fix it.

Um, I don't think I am serialising the exception; heres my code:

        IndexTankClient client = new IndexTankClient("http://:xxxxxxxxx@xxxx.api.indextank.com");

        Index index = client.GetIndex("Cpdlectures");

        string queryText = txtSearch.Text;
        if (queryText != string.Empty)
        {
            Query query = new Query(queryText);
            SearchResult result = index.Search(query);
            Console.WriteLine(string.Format("There were {0} matches found for '{1}'.", result.Matches, result.QueryText));
            Console.WriteLine(string.Format("The search took {0} seconds.", result.SearchTime));
            string str = "";
            foreach (ResultDocument document in result.ResultDocuments)
            {
                str += document.DocumentId + ",";
            }
            if (str != string.Empty)
            {
                str = str.Substring(0, str.Length - 1);
                odsSearch.SelectParameters["items"].DefaultValue = str;
                odsSearch.Select();
                odsSearch.DataBind();
                videosGrid.DataBind();
            }

        }

I'm not too sure if the GetObjectData method is called before the server error occurs though (it looks like the code does execute to GetIndex, but theres no error thrown on my local machine. (let me know and I'll be happy to apply some trouble shooting tests) 

Ha, These changes in .NET 4 are the reason why this method requires Medium Trust. Had this been published in .NET 3.5, apparently it would have worked on Godaddy.

 

Coordinator
Oct 7, 2011 at 5:26 PM

Okely dokely. Uploaded some new source that I think will nail this.

http://indextankdotnet.codeplex.com/SourceControl/changeset/changes/a586512a46c9

Please give this a try and kindly report back. I appreciate your patience helping me out with it.

Oct 7, 2011 at 6:07 PM
Edited Oct 7, 2011 at 6:19 PM

Thanks a lot LDumond, that's fixed it. http://cpdlectures.com/testIndexTank.aspx

is this fix in the latest version now, or when will you update the changes?

 

Thanks again for your speedy responses,

Shaun.

Coordinator
Oct 7, 2011 at 6:13 PM

 

I will be updating the download and the Nuget package in an hour or two. I will tweet it (@leedumond) when it is all done. 

New version will be 0.8.4.0

Coordinator
Oct 7, 2011 at 7:26 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.