Reputation: 61
I have simple mvc 4 application which tries to read data from a CSV file from server. When running on Local Host, it works fine. But when I uploaded app to godaddy server, I am getting following error while trying to read the file
System.TypeAccessException: Attempt by method 'DynamicClass.lambda_method(System.Runtime.CompilerServices.Closure)' to access type 'System.Linq.OrderedEnumerable
2<CSVU.Models.DataTableEntry,System.Int32>' failed. at lambda_method(Closure ) at System.Linq.EnumerableExecutor
1.Execute() at System.Linq.EnumerableQuery1.System.Linq.IQueryProvider.Execute[S](Expression expression) at System.Linq.Queryable.Count[TSource](IQueryable
1 source) at PagedList.PagedList1..ctor(IQueryable
1 superset, Int32 pageNumber, Int32 pageSize) at PagedList.PagedList1..ctor(IEnumerable
1 superset, Int32 pageNumber, Int32 pageSize) at PagedList.PagedListExtensions.ToPagedList[T](IEnumerable1 superset, Int32 pageNumber, Int32 pageSize) at CSVU.Controllers.FilesController.ViewCSVData(Int32 id, Nullable
1 page) in G:\Mayur Muley\Project\Caliber Group\CSVU\CSVU\Controllers\FilesController.cs:line 200 at
There are many more lines of it..
Upvotes: 0
Views: 256
Reputation: 61
I got it resolved.. I dont know how but following are solutions I tried. Each solution must use its predecessor solution. For each solution I published app to godaddy with newer assemblies.
I tried signing my assembly.
When I was paging a list of my custom object. I wrote this code
var temp = myPrevList.OrderBy(x=> x.IntegerColumn);
IPagedList listToSendToView = temp.ToPagedList(1,10);
Instead of this
IPagedList listToSendToView = myPrevList.OrderBy(x=> x.IntegerColumn).ToPagedList(1,10);
Then tried changing trust level by signing assembly with different key.
Then tried solution suggested by @timothyclifford of implementing security roles, here I tried Level1. Published to godaddy. -> got no +ve results
Then tried Level2, same outcomes produced, no use.
Then tried None level, same outcomes produced, no use.
Finally I tried removing security rule set in step 4,5,6 and published and MIRACLE... IT worked..! I still don't know how and why it worked.
Thanks @timothyclifford.
Upvotes: 0
Reputation: 6969
Reading https://github.com/troygoode/PagedList/issues/68
It sounds like GoDaddy have some legacy/weird security configurations.
Have you tried adding the following to your AssemblyInfo.cs
file?
[assembly: SecurityRules(SecurityRuleSet.Level1)]
It may also be possible you're compiling to .NET4 but GoDaddy is .NET2, I would check this also to be sure.
More reading here https://msdn.microsoft.com/en-us/library/system.security.securityruleset(v=vs.110).aspx
Upvotes: 1