The value of the property 'lifetime' cannot be parsed

Mar 25, 2008 at 9:43 PM
I just downloaded the latest release of Unity (24 march). I recompiled my project and got an error on the following part:

_container = new UnityContainer();
UnityConfigurationSection section
= (UnityConfigurationSection)ConfigurationManager.GetSection("unity");

Apparently GetConfigCommand() does not exist anymore. I just removed it. Then everything compiles but I do get an error when running the app.

I get the following error:
The value of the property 'lifetime' cannot be parsed. The error is: Object reference not set to an instance of an object.
mapTo="Synopsis.Business.ApplicationReferences, Synopsis.Business" lifetime="Singleton"/>

Does anyone have an idea what can be causing this?
Mar 26, 2008 at 1:18 AM
GetConfigCommand() is indeed gone.

Also, the lifetime attribute has changed to a separate <lifetime> child element. Please see the documentation for details (and if the docs don't make sense, please let me know so I can a) get you working again and b) fix the docs).

Mar 26, 2008 at 2:10 PM
I can get it to work. I have another problem however, but I will start a new topic for this one.

btw, the docs are no longer in sync with the most recent codebase. There is nothing in there about a separate <lifetime> object.

Feb 10, 2010 at 2:07 PM

I'm getting this same exception.  How did you get past it?

Feb 11, 2010 at 6:29 AM

You should separate the lifetime as a separate element and not an attribute of the <type> element.

<type type="Something.SomeInterface, Something" mapTo="Something.SomeClass, Something" >
    <lifetime type="singleton" />

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.