Partial Trust and ObjectBuilder woes V 3.0 / V 3.1

Topics: Data Access Application Block, Enterprise Library Core, General discussion
May 25, 2007 at 7:47 PM
Hi Team,

Life was simple under the patched 2.0 EntLib and developing in my partial trust environment was just fine...until 3.0 and 3.1.

No matter matter what I do, I'm continually bumping up against this exception:

Security Exception 
Description: The application attempted to perform an operation not allowed by the security policy.  
To grant this application the required permission please contact your system administrator or change the 
application's trust level in the configuration file. 
 
Exception Details: System.Security.SecurityException: That assembly does not allow partially trusted callers.
 
Source Error: 
An unhandled exception was generated during the execution of the current web request. Information regarding 
the origin and location of the exception can be identified using the exception stack trace below.  
 
Stack Trace: 
[SecurityException: That assembly does not allow partially trusted callers.]
   Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory..cctor() +0
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.210 

I guess this is because the ObjectBuilder assembly is signed?

I'm building my project against the unsigned locally build EntLib.

Is the correct work around to build an unsigned ObjectBuilder from http://www.codeplex.com/ObjectBuilder then rebuild Ent Lib against that?

This all worked nicely in 2.0 + patch.

Cheers
Kev
May 28, 2007 at 6:08 PM
I don't quite fully understand this piece of Enterprise Library as well as things have changed on how it works.

There is quite a bit of documentation on partial trust / medium trust support in the documentation that may be able to shed some light on your question. Check:

Design of the Enterprise Library > Support for Partially Trusted Applications

Deploying the Enterprise Library > Customizing the Medium Trust Policy

Regards,

Dave

______________________________

David Hayden
Microsoft MVP C#
May 29, 2007 at 1:16 AM
Hi Kev -

You are correct that the issue here is that the ObjectBuilder assembly is signed (but doesn't have APTCA). The best workaround is to download the source from /ObjectBuilder and compile it.

Ideally the p&p team can look at switching on APTCA for future releases to avoid this issue.

Tom
Jun 7, 2007 at 5:51 PM
Thanks. I do not get error "That assembly does not allow partially trusted callers." after building an unsigned ObjectBuilder and then rebuilding Ent Lib 3.1. However, there is still another security exception in run time on a windows 2003 server. I have also tried stronged name, but neither one can resolve this security issue. Please help. Thank you.

Security Exception
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Configuration.ConfigurationPermission, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' failed.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


SecurityException: Request for the permission of type 'System.Configuration.ConfigurationPermission, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' failed.
System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0
System.Security.CodeAccessPermission.Demand() +59
System.Configuration.BaseConfigurationRecord.CheckPermissionAllowed(String configKey, Boolean requirePermission, Boolean isTrustedWithoutAptca) +65


Regards,

Vincent

Jun 18, 2007 at 10:25 PM
Vincent,

I fixed this by editing web.config. Find your <section name="DataConfiguration" and modify it like so:

<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null" requirePermission="false" />

Note that, like you, I had to download ObjectBuilder source, build it, and rebuild EntLib 3.1. Hopefully Entlib 3.2 will have real "out of the box" medium-trust support, as I don't like to make custom builds of what I consider "official" Microsoft runtimes.
Jun 19, 2007 at 1:33 PM
Vincent, Derek

You can use the configuration tool to set the "requirePermission" attribute to "false"; it will show up in the properties for the section as "RequirePermission".

Fernando
Aug 28, 2007 at 4:05 PM
Hi,

Can anyone please explain me how to handle? I've installed EntLib 3.1, using the Data Application Block in .NET 3.0, Visual Studio 2008 Beta2. My solutions is a 3 tier solution, the Data App Block only for the Data Acces Layer.

All works fine on my dev machine (.Net test server), but when uploading to the production server (a shared hosting provider) I get this error:


============================================================================================
Security Exception
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

Exception Details: System.Security.SecurityException: That assembly does not allow partially trusted callers.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


SecurityException: That assembly does not allow partially trusted callers.
Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory..cctor() +0

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.210

============================================================================================



My Web.config file:

<configSections>
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null" requirePermission="false" />
</configSections>
<dataConfiguration defaultDatabase="test" />
<connectionStrings>
<add name="test" connectionString="Data Source=xxxxxxx;Initial Catalog=xxxxxx;User ID=xxxxxxx;Password=xxxxxxx"
providerName="System.Data.SqlClient" />
</connectionStrings>


Please help me. I read something about building the ObjectBuilder source code, and then rebuild the EntLib, but I realy don't know. I've added a reference to the Microsoft.Practices.EnterpriseLibrary.Common.dll and Microsoft.Practices.EnterpriseLibrary.Data.dll from the build EntLib3Src\App Blocks\bin directory. That's correct? I hope someone can help me, and can explain me how to handle...

Many many thanks :)


Aug 29, 2007 at 8:37 AM
Yes you are unfortunately correct that it is necessary to rebuild ObjectBuilder from the soruce (get it from /objectbuilder), and either leave it unsigned, or add the AllowPartiallyTrustedCallers attribute and sign it. Sorry we missed this - hopefully it's something the EntLib or ObjectBuilder teams can look at in the future.

Tom
Aug 29, 2007 at 10:17 AM
Hi Tom (Also a Hollander ? ;))

Can you please give me a detailed list of the steps which I have to do?

I've a directory C:\EntLib3Src\App Blocks\bin where the EntLib dll's are build in via the BuildLibrary.bat. Then I made a reference to the .common.dll and the .data.dll files in this directory. After that I made the web.config file (see above).

Which steps do I need to take?

Other questions:

- How to rebuild ObjectBuilder?
- Which version do I need to download? (with source or without source).
- What is "leave it unsigned". ==> how can I sign a build?
- How to "add the AllowPartiallyTrustedCallers" ?? And Where do I need to add this?
- How to deploy the project after this to my hosted webserver? Can I only click on deploy on my website (which have 2 projects in the same solution (BLL and DAL) and the EntLib assemblies are build too, or do I have to do this manually?



tomhollander wrote:
Yes you are unfortunately correct that it is necessary to rebuild ObjectBuilder from the soruce (get it from /objectbuilder), and either leave it unsigned, or add the AllowPartiallyTrustedCallers attribute and sign it. Sorry we missed this - hopefully it's something the EntLib or ObjectBuilder teams can look at in the future.

Tom

Aug 29, 2007 at 12:30 PM
Hi All,

Been away for a bit and I see there's been a flurry of activity on this thread so thought I'd share with everyone what I did.

I basically grabbed the ObjectBuilder source then built an unsigned version. I then copied the EL code to a new folder e.g. c:\appsdev\EL3.1u, opened the solution up and changed all the references to the signed object builder to the new unsigned build of ObjectBuilder and then rebuilt all of EL using the batch file. Job done and worked a treat. Initially when I opened the thread I thought I was missing something, but Tom confirmed suspicions about lack of APTCA on the build of ObjectBuilder in 3.1 release.

If I may be so bold as to suggest that the 3.2 release could build as signed and unsigned? Unsigned builds are a bit more handy to work when deploying to shared hosting environments.

Cheers
Kev
Aug 29, 2007 at 1:14 PM
Kevinkenny,

Can you give me a step by step guide for the whole process?



kevinkenny wrote:
Hi All,

Been away for a bit and I see there's been a flurry of activity on this thread so thought I'd share with everyone what I did.

I basically grabbed the ObjectBuilder source then built an unsigned version. I then copied the EL code to a new folder e.g. c:\appsdev\EL3.1u, opened the solution up and changed all the references to the signed object builder to the new unsigned build of ObjectBuilder and then rebuilt all of EL using the batch file. Job done and worked a treat. Initially when I opened the thread I thought I was missing something, but Tom confirmed suspicions about lack of APTCA on the build of ObjectBuilder in 3.1 release.

If I may be so bold as to suggest that the 3.2 release could build as signed and unsigned? Unsigned builds are a bit more handy to work when deploying to shared hosting environments.

Cheers
Kev


Aug 29, 2007 at 3:18 PM
Webps:

I seem to remember the steps were....

1. Download ObjectBuilder source from codeplex and build it.

2. Copy the source code folder structure for EL 3.1 to a new folder (just so you don't contaminate the original source).

3. Open the EnterpriseLibrary.sln solution file in VS05.

4. Track down and replace all references to signed object builder with the unsigned one.

5. BuildLibrary.bat

Kev
Sep 3, 2007 at 3:10 PM
I've just tried going through this process, but hit some snags.

I download ObjectBuilder, and built it as an unsigned assembly.

I then opened up the EntLib solution and changed the reference of one of the projects (the Logger, which is the one I'm interested in) to point to my unsigned assembly. However, when I tried building the Logger project, I got the following message:

Error 1 'Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.TraceListenerAsssembler' does not implement interface member 'Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.IAssembler<System.Diagnostics.TraceListener,Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.TraceListenerData>.Assemble(Microsoft.Practices.ObjectBuilder.IBuilderContext, Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.TraceListenerData, Microsoft.Practices.EnterpriseLibrary.Common.Configuration.IConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.ConfigurationReflectionCache)' D:\EntLib3Src\App Blocks\Src\Logging\Configuration\TraceListenerAsssembler.cs 25 24 Logging

This was one of 11 such errors - can anyone suggest where I'm going wrong?

Many thanks
Gerry
Sep 3, 2007 at 3:19 PM
Hi,

Changing just the logging project will not be enough, as it depends on the Common project. Try again after changing all the references (a global S&R for the OB assembly name on *.csproj files should do the trick).

Regards,
Fernando
Sep 4, 2007 at 8:44 AM
Ok, that worked thanks. However, I've now hit a new problem.

I've done all the above, and then moved the newly generated assemblies into the bin directory of my home site. I now get the following error:

---------------------------------------------------------------------------------------------------------------
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Access is denied.
---------------------------------------------------------------------------------------------------------------

Is there something obvious I'm missing?

Thanks again.
Sep 4, 2007 at 9:11 AM

Kevinkenny,

Is there a possiblity that someone else does this for me and send me the files? After days of trying, it won't work :(.


kevinkenny wrote:
Webps:

I seem to remember the steps were....

1. Download ObjectBuilder source from codeplex and build it.

2. Copy the source code folder structure for EL 3.1 to a new folder (just so you don't contaminate the original source).

3. Open the EnterpriseLibrary.sln solution file in VS05.

4. Track down and replace all references to signed object builder with the unsigned one.

5. BuildLibrary.bat

Kev


Sep 4, 2007 at 9:33 AM
Edited Sep 4, 2007 at 9:38 AM
And another problemette... :o)

I just went to rebuild my page, and I'm getting generation errors there now...it fails, as my referenced assemblies (my newly rebuilt EntLib assemblies, including ObjectBuilder) do not have strong names.

Can I just clarify a few issues please

1) As I'm strong naming my assemblies, all assemblies I reference must also be strong named, correct? Therefore, if I rebuild ObjectBuilder to allow partially trusted calls, I need to strong name it?
2) I need to ensure EntLib 3.1 calls my own version of ObjectBuilder, which means I need to change the references within EntLib 3.1 to refer to my own version, and then rebuild EntLib 3.1. This rebuilt EntLib 3.1 must also be strong named. This will not happen by default, and therefore I need to go through all the projects within EntLib 3.1 and sign each assembly?
3) Once that's done, I can update the references within my solution to point to my newly created EntLib 3.1 assemblies, and my solution should theoretically build at that point.
4) I can then put all the DLLs in my bin directory of my home site...is there likely to be anything else to add (for example, do I need to make any changes to my web.config?)

Many thanks
Gerry
Sep 4, 2007 at 2:07 PM
Hi,


1) As I'm strong naming my assemblies, all assemblies I reference must also be strong named, correct? Therefore, if I rebuild ObjectBuilder to allow partially trusted calls, I need to strong name it?

Yes, and yes. Keep in mind that if you want to sign the OB assembly, you will need to add the APTCA (which wouldn't be necessary otherwise).

2) I need to ensure EntLib 3.1 calls my own version of ObjectBuilder, which means I need to change the references within EntLib 3.1 to refer to my own version, and then rebuild EntLib 3.1. This rebuilt EntLib 3.1 must also be strong named. This will not happen by default, and therefore I need to go through all the projects within EntLib 3.1 and sign each assembly?

You can use the Strong Naming guidance package to do the heavy lifting for you. You will need to install GAX though.

3) Once that's done, I can update the references within my solution to point to my newly created EntLib 3.1 assemblies, and my solution should theoretically build at that point.

Yes

4) I can then put all the DLLs in my bin directory of my home site...is there likely to be anything else to add (for example, do I need to make any changes to my web.config?)

You will have a new set of assemblies, with new fully qualified names. If you have any reference to these full names in your configuration files, you will need to update them. Only the public key token should need changing.

Regards,
Fernando
Sep 4, 2007 at 2:11 PM
Webps,


Webps wrote:

Kevinkenny,

Is there a possiblity that someone else does this for me and send me the files? After days of trying, it won't work :(.



What kind of problems are you having with the process?

Regards,
Fernando
Sep 4, 2007 at 3:14 PM
I don't know the exact steps to follow to get it working :(. Where can I find the files? Which directory is used (EntLib3 or the program files\enterprise library?), where to find the buildlibrary? And how to handle?



fsimonazzi wrote:
Webps,


Webps wrote:

Kevinkenny,

Is there a possiblity that someone else does this for me and send me the files? After days of trying, it won't work :(.



What kind of problems are you having with the process?

Regards,
Fernando

Sep 4, 2007 at 3:37 PM
Hi Webps,

kevinkenny posted the steps, indicating where to get the files from and suggesting you use a new copy of the sources to avoid contaminating the original. Can you describe the specific issues you're facing regarding those steps?


kevinkenny wrote:

1. Download ObjectBuilder source from codeplex and build it.

2. Copy the source code folder structure for EL 3.1 to a new folder (just so you don't contaminate the original source).

3. Open the EnterpriseLibrary.sln solution file in VS05.

4. Track down and replace all references to signed object builder with the unsigned one.

5. BuildLibrary.bat


FWIW, you can take care of step #4 by doing a global "replace in files" with these parameters:
- Find what? <Reference Include="Microsoft.Practices.ObjectBuilder, Version=1.0.51206.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
- Replace with? <Reference Include="Microsoft.Practices.ObjectBuilder, Version=1.0.51206.0, Culture=neutral, PublicKeyToken=null, processorArchitecture=MSIL">
- Look in? the folder for your new copy of the entlib source
- Look at these file types? *.csproj

And just copy the OB dll you built in step #1 to the Lib folder in your EntLib source code folder, replacing the existing, signed binary.

Hope this helps,
Fernando
Sep 4, 2007 at 5:28 PM
Ok, my problems:

1) How to build step 1? Open the source in VS2005 and then build solution? Then get the DLL from the builded folder?

2) This is the builded C:\EntLib3Src\App Blocks folder, with "BuildLibrary.bat" in it? Do I have to run this first?

3) The enterpriselibrary.sln file from the (default) C:\EntLib3Src\App Blocks (or a copy of this?).

4) Ok, I get your description.

5) The same BuildLibrary as in step 2?


=> Other questions:

After I builded this again (in step 5), what steps do I need to take care of after this? In my own project get a reference to the new builded files in the App Blocks\Bin folder? I need the data and the common dll.



fsimonazzi wrote:
Hi Webps,

kevinkenny posted the steps, indicating where to get the files from and suggesting you use a new copy of the sources to avoid contaminating the original. Can you describe the specific issues you're facing regarding those steps?


kevinkenny wrote:

1. Download ObjectBuilder source from codeplex and build it.

2. Copy the source code folder structure for EL 3.1 to a new folder (just so you don't contaminate the original source).

3. Open the EnterpriseLibrary.sln solution file in VS05.

4. Track down and replace all references to signed object builder with the unsigned one.

5. BuildLibrary.bat


FWIW, you can take care of step #4 by doing a global "replace in files" with these parameters:
- Find what? <Reference Include="Microsoft.Practices.ObjectBuilder, Version=1.0.51206.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
- Replace with? <Reference Include="Microsoft.Practices.ObjectBuilder, Version=1.0.51206.0, Culture=neutral, PublicKeyToken=null, processorArchitecture=MSIL">
- Look in? the folder for your new copy of the entlib source
- Look at these file types? *.csproj

And just copy the OB dll you built in step #1 to the Lib folder in your EntLib source code folder, replacing the existing, signed binary.

Hope this helps,
Fernando


Sep 4, 2007 at 5:38 PM
Webps:

PM me and I'll send you a link to an upload of an unsigned build for you to grab.


Kev




Webps wrote:
Ok, my problems:

1) How to build step 1? Open the source in VS2005 and then build solution? Then get the DLL from the builded folder?

2) This is the builded C:\EntLib3Src\App Blocks folder, with "BuildLibrary.bat" in it? Do I have to run this first?

3) The enterpriselibrary.sln file from the (default) C:\EntLib3Src\App Blocks (or a copy of this?).

4) Ok, I get your description.

5) The same BuildLibrary as in step 2?


=> Other questions:

After I builded this again (in step 5), what steps do I need to take care of after this? In my own project get a reference to the new builded files in the App Blocks\Bin folder? I need the data and the common dll.



fsimonazzi wrote:
Hi Webps,

kevinkenny posted the steps, indicating where to get the files from and suggesting you use a new copy of the sources to avoid contaminating the original. Can you describe the specific issues you're facing regarding those steps?


kevinkenny wrote:

1. Download ObjectBuilder source from codeplex and build it.

2. Copy the source code folder structure for EL 3.1 to a new folder (just so you don't contaminate the original source).

3. Open the EnterpriseLibrary.sln solution file in VS05.

4. Track down and replace all references to signed object builder with the unsigned one.

5. BuildLibrary.bat


FWIW, you can take care of step #4 by doing a global "replace in files" with these parameters:
- Find what? <Reference Include="Microsoft.Practices.ObjectBuilder, Version=1.0.51206.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
- Replace with? <Reference Include="Microsoft.Practices.ObjectBuilder, Version=1.0.51206.0, Culture=neutral, PublicKeyToken=null, processorArchitecture=MSIL">
- Look in? the folder for your new copy of the entlib source
- Look at these file types? *.csproj

And just copy the OB dll you built in step #1 to the Lib folder in your EntLib source code folder, replacing the existing, signed binary.

Hope this helps,
Fernando



Dec 11, 2007 at 5:19 PM
SOLUTION:
Okay, so I wasted 2 days of time, trying to get my finished product running on a GoDaddy.com shared hosting plan with EL 3.1. I read through all of the posts that I could find and there was just no "Quick Fix". It actually only took 20 minutes to go through recompile steps listed above in order to get an unsigned version of the EL 3.1. I did my project in VB rather that C# so, I had to go download the C# Express in order to recompile it. No big deal though.
STEPS:
1) I downloaded the Object Builder source from http://www.codeplex.com/objectbuilder
The link is in the upper right-hand corner as of writing this (12/11/2007). I downloaded the ZIP and extracted it to my C drive. I opened up the C# project and literally just hit Rebuild.

2) From the "Microsoft Patterns & Practices" Start menu, I clicked Install Source code. This dropped the source code in the C:\EntLib3Src. I took someone elses suggestion listed above and made a copy of the source as to not contaminate the original.
3) I copied the DLL built in step 1 to the "LIB" folder of my copied source in step 2. In my case "C:\EntLib3Src_U\App Blocks\Lib\" Each project in the Enterprise Library seems to reference that copy of the ojbect builder.
4) I opened the EnterpriseLibrary solution file located in the "C:\EntLib3Src_U\App Blocks folder."
5) I hit Rebuild
6) I then went and opened my original web project slated for the GoDaddy servers, and removed the references and then re-added them to the project. I pointed to each of the DLL's in the C:\EntLib3Src_U\App Blocks sub folders.
I was only using 5 or 6. I hit rebuild on my project and then ran it to make sure it still worked.
7) I copied the DLL's to the BIN folder of my web project via FTP.

It all works now. I am posting this because I was put off by what sounded like a lot of work that I was not smart enough to accomplish. In the end, I wish I would have just heeded everyone's advice above and followed these steps. I would have been running down the road in 20 minutes. I might have been able to just rebuild the ObjectBuilder and copy it to the LIB folder and run the BuildLibrary.Bat file, but I thought there would be more to it. I did notice there is a compiled DLL in the current ObjectBuilder download (http://www.codeplex.com/objectbuilder ). I also might have been able to simply download this dll and copy it to the LIB source folder and run the BuildLibrary Bat file.

I hope this helps others.

~wauna~
Jan 2, 2008 at 10:53 AM
I got the "That assembly does not allow partially trusted callers" exception for my data layer assembly. It was internally using the DAAB of Ent Lib 3.1 . I then removed the strong name for my Data layer assembly, and also added the 'AllowPartiallyTrustedCaller()' attribute to the DAAB project in the Ent Lib 3.1 (which i got by clicking the 'Enterprise Library Source Code Installer' option in my Program Files -> Enterprise Library menu).

Now i get the same error, but the Stack trace error as :-

SecurityException: That assembly does not allow partially trusted callers.]
Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory..cctor() +0


So then i clicked on the 'Source' Tab in the Object Builder page (as pointed by several mails above), downloaded the file 'Object Builder-29426.zip', unzipped it, checked it was not signed (it was not), added the APTCA attribute, built it, copied the DLL to the LIB folder of the Ent Lib 3.1 , built that, took the DAAB DLL, copied it to my web application and referenced it, published the site.

However, i continue to get the above error with regard to ObjectBuilder.

Any hints ?

Chak.
Jan 2, 2008 at 11:31 AM
You need to replace the OB assembly too. Also, you need the APTCA only if you're going to sign EntLib and OB with your own key.

Fernando
May 19, 2008 at 8:22 AM

I just want to thank WaunaPlay for sumarizing the steps clearly on how to do make the websites work for Shared web hostings that has Medium Trust level.  I have my account with GoDaddy and I have been fighting with this problem since more than week now.  Finally I hit this forum and the instructions fixed my problem. 

QUESTIONS:  Is this generated ObjectBuilder.dll assembly trustful?  I mean, how someone can certify that the ObjectBuilder source code does not content malicious code?  Is there any download of this objectbuilder source code available from Microsoft website?

Before I was getting the same error other have reported, but now is fixed with the suggrestion above on Dec 11 2007 at 12:19 PM by WaunaPlay :
--------------------------------------------------------------------------------------------

Security Exception

Description: The application attempted to perform an operation not allowed by the security policy.  To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

Exception Details: System.Security.SecurityException: That assembly does not allow partially trusted callers.
Source File: App_Web_dlbm53el.0.cs    Line: 0

Stack Trace:

[SecurityException: That assembly does not allow partially trusted callers.]
   DAL.Books..ctor() in Books.cs:17
   _Default.Page_Load(Object sender, EventArgs e) in Default.aspx.cs:15
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +33
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   System.Web.UI.Control.LoadRecursive() +47
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +7350
   System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +213
   System.Web.UI.Page.ProcessRequest() +86
   System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +18
   System.Web.UI.Page.ProcessRequest(HttpContext context) +49
   ASP.default_aspx.ProcessRequest(HttpContext context) in App_Web_dlbm53el.0.cs:0
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +358
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64


Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433 <!-- [SecurityException]: That assembly does not allow partially trusted callers. at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Assembly asm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed) at DAL.Books..ctor() at _Default.Page_Load(Object sender, EventArgs e) in g:\Proyectos\ASP.Net\Prodserver\WebsiteWithLocalDataAccess\WebUI\Default.aspx.cs:line 15 at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest() at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) at System.Web.UI.Page.ProcessRequest(HttpContext context) at ASP.default_aspx.ProcessRequest(HttpContext context) in c:\windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\webdev1\9ef5c7e6\3b999bc4\App_Web_dlbm53el.0.cs:line 0 at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) --><!-- This error page might contain sensitive information because ASP.NET is configured to show verbose error messages using <customErrors mode="Off"/>. Consider using <customErrors mode="On"/> or <customErrors mode="RemoteOnly"/> in production environments.-->

--------------------------------------------------------------------------------------------

May 19, 2008 at 4:12 PM

Hi,

If I understand your situation correctly, you want to make sure the sources you can download from Codeplex match the binary bundled with EntLib. If that's the case, you can use the Reflector Diff Add-In to compare the assembly built from the source code (using the Release configuration) and the bundled binary.

Hope this helps,
Fernando