My favorites | Sign in
Project Logo
                
New issue | Search
for
| Advanced search | Search tips
Issue 11: Enable deployment to Medium Trust Environment
5 people starred this issue and may be notified of changes. Back to list
Status:  Accepted
Owner:  ----
Type-Enhancement
Priority-Medium
Component-Installer
Security


Sign in to add a comment
 
Reported by gavinjoyce, Jul 12, 2007
I haven't tried to deploy to an medium trust environment, but it probably
won't work.

Jose Guia reported the following error when deploying to CrystalTech:

Error    1    Could not load file or assembly
'Microsoft.ApplicationBlocks.ConfigurationManagement, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null' or one of its dependencies. Failed to
grant minimum permission requests. (Exception from HRESULT: 0x80131417)       
Comment 1 by gavinjoyce, Jul 20, 2007
(No comment was entered for this change.)
Owner: ---
Comment 2 by yesthatmcgurk, Nov 16, 2007
Well, I'm looking at deployment to a shared hosting environment.  I'll report any 
problems I have here.
Comment 3 by yesthatmcgurk, Dec 01, 2007
Scratch that; my host supposedly runs full trust.

Comment 4 by antoniochagoury, Apr 08, 2008
Hi Folks,
Just tried deploying on CrystalTech hosting and had no luck. I am getting the same
error as above.
Do you have any clues as what this might be?

Thanks
Comment 5 by williamwgant, May 01, 2008
This issue looks similar:

http://msmvps.com/blogs/shahed/archive/2007/07/16/loading-providers-in-medium-trust-mode-using-webconfigurationmanager.aspx

There is also some guidance there that might help replicate the issue in a
development environment.
Comment 6 by williamwgant, May 01, 2008
Confirmed.

You can replicate the issue by adding <trust level="Medium"/> under System.Web in
web.config.

However, I'm still not sure what to do about it.
Comment 7 by williamwgant, May 01, 2008
Ok, I did a bit more digging. I note that you are using Subsonic's build provider,
which requires full trust.

http://subsonicproject.com/configuration/setting-up-your-web-app-config/

"If you will be deploying your application to an ISP that uses shared hosting, you
probably won't be able to use the BuildProvider since it won't run in MediumTrust. If
this is the case, you can use SubSonicCentral (the web site downloaded with SubSonic)
to generate the code for you, or you can use the Command Line tool."

So, we can use the commandline tool to generate the relevant code. It's not as clean
and easy as the build provider, but at least then we can deploy to cheaper, more
restrictive web hosts.

Anybody want to take a shot at doing this?
Comment 8 by gavinjoyce, May 02, 2008
We already use the command tool to do the SubSonic code generation. If there is
SubSonic build provider configuration in the project it should be removed.
Comment 9 by williamwgant, May 02, 2008
Ok,
I removed it on mine, but there is still an error resulting from the
Microsoft.ApplicationBlocks.ConfigurationManagement. Looking around a bit further, I
found the following tutorial that shows how to get these libraries to load in medium
trust.

Basically, the application blocks code requires full trust, but there is a patch
available
(http://www.codeplex.com/entlib/Release/ProjectReleases.aspx?ReleaseId=1339) that
will let you do things under partial trust.
----------------------------------------
But see here is a solution for u :)

i Have seceded  through the way

1)Download the latest version of Enterprise Library :
http://www.microsoft.com/downloads/details.aspx?familyid=5a14e870-406b-4f2a-b723-97ba84ae80b5&displaylang=en
and install (by default, it will be installed under C:\Program Files\Microsoft
Enterprise Library January 2006)


2)Download the patch to run EnterPriselibrary in Medium trust :
http://www.codeplex.com/entlib/Release/ProjectReleases.aspx?ReleaseId=1339

3)Replace the src and de unittests directories from the Enterprise library by the
ones in the patch

4)run 2 batch files which come with the EntLib.
First, run BuildLibrary.bat, then CopyAssemblies.bat (both files are to be found in
the same folder)

5)Replace the references in your webproject (Microsoft.Practices......dll) by the
newly compiled under the enterprise library. Warning : all the dll's seem to be
gathered in one bin directory under the enterprise library.

6)Change the web.config, add requirePermission="false" to the <section
name="netTiersService" type="MySan.DataAccessL .... line (ignore the warning you will
get about the non declared attribute)


7)Rebuild your webproject and publish ... it will work
--------------------------------------------------------
 

Comment 10 by williamwgant, May 20, 2008
Ok,
I did even more digging. I was able to get this working on medium trust, but I've
made other modifications. I basically ripped out the enterprise library stuff because
it appeared to be part of the problem (experimentation has proven this - you might be
able to get by with one of the newer builds).

Regardless, it appears that all I had to do once I got rid of the enterprise library
cruft, I was able to simply add the requirePermission=false attribute to the
<section/> nodes in the web.config.

If someone smarter than me can take this and run with it, we might be able to make
this app where it can run on most web hosts (or at least more).

I've attached a sample web config for clarity.
Web.config
24.2 KB   Download
Comment 11 by williamwgant, Aug 08, 2008
Are there any updates on this one yet?
Sign in to add a comment

Hosted by Google Code