DependencyInjection

Posts   
 
    
simon831
User
Posts: 152
Joined: 19-Jan-2006
# Posted on: 25-Jan-2008 18:00:11   

Trying to get this DependencyInjection to work. There are no errors, but I can't get it to work at all - the property that should be getting an injection is always null. I assume its some basic omission.

The edited highlights of my code is:

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"> <configSections> <section name="dependencyInjectionInformation" type="SD.LLBLGen.Pro.ORMSupportClasses.DependencyInjectionSectionHandler, SD.LLBLGen.Pro.ORMSupportClasses.NET20, Version=2.5.7.831,Culture=neutral, PublicKeyToken=ca73b74ba4e3ff27"/> </configSections> <dependencyInjectionInformation> <additionalAssemblies> <assembly filename="MyNamespace.EntityLayer.dll"/> </additionalAssemblies> </dependencyInjectionInformation>

namespace MyNamespace { [DependencyInjectionInfo(typeof(OrderDetailEntity), "ConfigurationInjection")] public class ConfigManager { } }

namespace MyNamespace.EntityClasses
{
    public partial class OrderDetailEntity
    {
    [XmlIgnore]
    private ConfigManager configurationInjection;
    public ConfigManager ConfigurationInjection
    {
        get { return configurationInjection; }
        set
        {
            configurationInjection = value;
        }
    }
}
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 27-Jan-2008 11:30:04   

THe assembly where MyNamespace is located in, is that indeed named MyNamespace.EntityLayer.dll ? Is this in a webapp or winforms app? I also find this odd: <section ... SD.LLBLGen.Pro.ORMSupportClasses.DependencyInjectionSectionHandler, SD.LLBLGen.Pro.ORMSupportClasses.NET20, Version=2.5.7.831,Culture=neutral, PublicKeyToken=ca73b74ba4e3ff27...

This doesn't work, you specified the FILEversion, but assembly signatures use the ASSEMBLYversion, which is 2.5.0.0

So it should be: <section name="dependencyInjectionInformation" type="SD.LLBLGen.Pro.ORMSupportClasses.DependencyInjectionSectionHandler, SD.LLBLGen.Pro.ORMSupportClasses.NET20, Version=2.5.0.0,Culture=neutral, PublicKeyToken=ca73b74ba4e3ff27"/>

(please also use a later runtime build than august 31st wink )

Frans Bouma | Lead developer LLBLGen Pro
simon831
User
Posts: 152
Joined: 19-Jan-2006
# Posted on: 28-Jan-2008 00:03:31   

I have upgraded to the latest llb build and the injection does not happen. There is no error, but the property remains null.

Otis wrote:

is that indeed named MyNamespace.EntityLayer.dll ?

I've written 'MyNamespace' to indicate what I am doing - its really named after the company.project.EntityLayer.dll

Otis wrote:

Is this in a webapp or winforms app?

I am trying to get the web app working, but there is a win app in the same solution that I will work on next.

Otis wrote:

use the ASSEMBLYversion, which is 2.5.0.0

I've changed this back to 2.5.0.0. I was just experimenting around to get it working.

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 28-Jan-2008 10:13:50   

The following was noted in the documentation(speaking about DI in a Web App):

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.

simon831
User
Posts: 152
Joined: 19-Jan-2006
# Posted on: 28-Jan-2008 18:22:35   

Works great now, thanks.

Clever stuff this injection.