Recently i started developing a web app in which i use MongoDB and it
worked beautifully, that until i uploaded to my Windows Shared Hosting
where the security policy is set to "Medium Trust" and Asp.Net it
always gave me this error "[SecurityException: That assembly does not
allow partially trusted callers.]".
After some research and debugging i finally set my development server
with the same policy (Medium Trust), but in order to solve that error
i had to download the C# Driver source code and compile it again, but
this time adding the following lines to the "AssemblyInfo.cs" files of
the "Bson" and "Driver" classes.
Finally that error was gone "[SecurityException: That assembly does
not allow partially trusted callers.]", But now i'm getting this new
error "The type initializer for 'MongoDB.Bson.ObjectId' threw an
exception." and i have no idea what should be done in that case.
Any ideas ?
PS: C# .Net Driver's developers should consider adding those lines to
the next driver's version, or come up with some solution so that we
don't get those errors while running on Medium Trust .Net servers