Dependency Injection on IIS

Posts   
 
    
nasser
User
Posts: 12
Joined: 23-Jun-2004
# Posted on: 17-Apr-2009 19:42:20   

Hi,

I am getting an unhandled error trying to instantiate an entity in an IIS process. I am working on an asp.net mvc project. So far I have only used the test web server that comes with VS. Today I wanted to deploy the application to the local IIS and failed with a security error. The details of the error are provided as an attachment. Following are the details of the environment: - LLBLGen 2.6 (October 6th 200sunglasses - Windows 2003 server with IIS 6.0 - Dot.Net 3.5 - mvc 1.0 - web.config has the following items

  <dependencyInjectionInformation>
    <additionalAssemblies>
      <assembly filename="SubsManager.dll"/>
    </additionalAssemblies>
    <instanceTypeFilters>
      <instanceTypeFilter namespace="SubsManager.Models.Validation"/>
      <instanceTypeFilter namespace="SubsManager.Models.Authorization" />
    </instanceTypeFilters>
  </dependencyInjectionInformation>
<trust level="Medium" />

I would really appreciate any suggestions as to what can be done to resolve this problem. I am assuming that the problem lies with the trust level granted to the application and the ability to perform reflection.

Greetings

Nasser

Attachments
Filename File size Added on Approval
DependencyInjectionSecurityError.txt 5,171 17-Apr-2009 19:42.34 Approved
daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 17-Apr-2009 20:48:56   

Please double check that your auditor assemblies (SubsManager.dll) are where they have to (/bin, for instance).

David Elizondo | LLBLGen Support Team
nasser
User
Posts: 12
Joined: 23-Jun-2004
# Posted on: 17-Apr-2009 21:05:34   

Dear Daelmo, thank you for the reply!

All dlls are in bin: - SubsManager.dll (app including validation, and authorization classes) - Models.dll - ModelsDBSpecific.dll

As I mentioned in my first posting, every thing works out really well in VS 2008 (with the test web server), deployment on IIS is causing a problem... Thank in advance for your assistance.

Best regards

Nasser

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 18-Apr-2009 05:56:25   

Nasser, please try to add requiresPermission="false" to the config section declaration.

David Elizondo | LLBLGen Support Team
nasser
User
Posts: 12
Joined: 23-Jun-2004
# Posted on: 21-Apr-2009 10:33:53   

Dear Daelmo,

I guess you mean

<section name="dependencyInjectionInformation" type="SD.LLBLGen.Pro.ORMSupportClasses.DependencyInjectionSectionHandler, SD.LLBLGen.Pro.ORMSupportClasses.NET20, Version=2.6.0.0, Culture=neutral, PublicKeyToken=ca73b74ba4e3ff27" requirePermission="false"/>

I did set the attribute, and I am still getting the same error running the app on IIS.

I have also tried to move the injectables (authorizer, validator) to a seperate library, but this didn't change much either.

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 21-Apr-2009 10:46:26   

Did you read the following section of the manual?

Auto-discovery doesn't work in website applications most of the time, so you should define Dependency Injection configuration settings in the web.config file as defined in the Manual discovery through dependencyInjectionInformation sections in the .config file below. You then also should specify the assemblies with the fullName attribute and the assembly's full name, instead of the file name like in the following example.

Example:

<assembly fullName="MyAuditorAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>

This is necessary because the reference to the assembly with the Dependency Injection classes isn't there, as the pages are often compiled in separate assemblies. After deployment, it might be that the references are there, but that's not always the case. Better is to define this in the config file using the dependencyInjectionInformation section.

When the injectable types are defined inside the webapplication however, the auto-discovery works.

So, please try the following:

<dependencyInjectionInformation>
        <additionalAssemblies>
            <assembly fullName="THE_ASSEMBLY_NAME, Version=1.0.3.4, Culture=neutral, PublicKeyToken=1b72b137335e31c3"/>
        </additionalAssemblies>
    </dependencyInjectionInformation> 

In Visual Studio, the assembly name can be viewed and changed through the project's property pages dialog box Also make sure you are using the correct version and PublicKeyToken.

nasser
User
Posts: 12
Joined: 23-Jun-2004
# Posted on: 21-Apr-2009 13:47:15   

That did it!

Thank you for the support!