Letractively / dotnetkicks

Automatically exported from code.google.com/p/dotnetkicks
1 stars 0 forks source link

Enable deployment to Medium Trust Environment #11

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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)       

Original issue reported on code.google.com by gavinjo...@gmail.com on 12 Jul 2007 at 9:09

GoogleCodeExporter commented 9 years ago

Original comment by gavinjo...@gmail.com on 20 Jul 2007 at 7:36

GoogleCodeExporter commented 9 years ago
Well, I'm looking at deployment to a shared hosting environment.  I'll report 
any 
problems I have here.

Original comment by yesthatm...@gmail.com on 16 Nov 2007 at 7:52

GoogleCodeExporter commented 9 years ago
Scratch that; my host supposedly runs full trust.

Original comment by yesthatm...@gmail.com on 2 Dec 2007 at 2:30

GoogleCodeExporter commented 9 years ago
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

Original comment by antonioc...@gmail.com on 8 Apr 2008 at 5:19

GoogleCodeExporter commented 9 years ago
This issue looks similar:

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

There is also some guidance there that might help replicate the issue in a
development environment.

Original comment by williamw...@gmail.com on 1 May 2008 at 2:28

GoogleCodeExporter commented 9 years ago
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.

Original comment by williamw...@gmail.com on 1 May 2008 at 5:33

GoogleCodeExporter commented 9 years ago
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?

Original comment by williamw...@gmail.com on 1 May 2008 at 5:38

GoogleCodeExporter commented 9 years ago
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.

Original comment by gavinjo...@gmail.com on 2 May 2008 at 9:45

GoogleCodeExporter commented 9 years ago
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
--------------------------------------------------------

Original comment by williamw...@gmail.com on 2 May 2008 at 1:12

GoogleCodeExporter commented 9 years ago
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.

Original comment by williamw...@gmail.com on 21 May 2008 at 12:45

Attachments:

GoogleCodeExporter commented 9 years ago
Are there any updates on this one yet?

Original comment by williamw...@gmail.com on 8 Aug 2008 at 6:09