Monday, November 28, 2011
Thursday, November 17, 2011
Leslie Lamport
Research documents: http://research.microsoft.com/en-us/um/people/lamport/pubs/pubs.htmlFriday, November 11, 2011
Thursday, November 10, 2011
Unity 2 - InjectionMember usage
IUnityContainer RegisterType(Type t, params InjectionMember[] injectionMembers);
What "injectionMembers" parameters are for?
The overload with the InjectionMember array is used, when you do not provide a configuration file, that the Unity container tells how to create an instance of the given type or if you want to create an instance on another way than defined in the configuration file. The overloads are used, when you want to configure an unity container without an configuration file. An InjectionMember can be an constructor, property or method call. The following code, taken from the Unity help, shows how to use InjectionMembers through the fluent interface of the container.
IUnityContainer myContainer = new UnityContainer();
myContainer.Configure<InjectedMembers>()
.ConfigureInjectionFor<MyObject>(
new InjectionConstructor(12, "Hello Unity!"),
new InjectionProperty("MyStringProperty", "SomeText"));
<type type="MyObject" mapTo="MyObject" name="MyObject">
<typeConfig extensionType="Microsoft.Practices.Unity.Configuration.TypeInjectionElement, Microsoft.Practices.Unity.Configuration">
<param name="someInt" parameterType="int">
<value value="12"/>
param>
<param name="someText" parameterType="string">
<value value="Hello Unity!"/>
param>
constructor>
<property name="MyStringProperty" propertyType="string">
<value value="SomeText"/>
property>
typeConfig> type>
var container = new UnityContainer();
container.RegisterType(new InjectionFactory((c) => Customer.NewCustomer()));
var newCustomer = container.Resolve();
Console.WriteLine(newCustomer.Name);
I use InjectionFactory when there is no chance to add an injection attribute for a third party class constructor or property. In this case you can create delegate creating an object.
HTTP Error 500.19 - Internal Server Error
Fix:
If your plan is to deploy to an IIS that has an Application Pool running in .net 4.0 you will need to cleanup the web.config that includes all the section Definitions that point to .net 3.5. The reason this fails is because these section definitions are already included in the root web.config in .NET 4.0 (see %windir%\microsoft.net\framework\v4.0.30319\config\machine.config) that include all the system.web.extensions declared already.
Another quick fix is to have the application pool set to 2.0 just as your development machine appears to have.
Delete or comment out all the system.web.extensions configuration section definitions and configuration section group definitions from the application-level
Subscribe to:
Posts (Atom)
Powered by Blogger.