Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Unity With Minimal Configuration

At work, we use Unity a lot. It's great at it's job, but the more you use it, the more your configuration file grows, the more runtime issues increase and the more you have to recreate your unity configuration for each test project.

So we end up with a huge unity configuration section that has to be duplicated accross several projects and when it comes time to deploy, you end up having to track down dlls that you forgot to add references to, but you only discover these at runtime. Not fun.

I'm guessing someone has come across this issue and has a solution. Ideally, I would like to figure out how to configure Unity in a way that makes use of convention over configuration and reduces runtime issues (ie, huge configuration files). Anyone know of a good way to implement Unity with minimal configuration?

Edit: One thing: I have to stick with only using Unity. Can't really switch to Ninject, etc.

like image 846
Don Fitz Avatar asked Apr 02 '11 01:04

Don Fitz


People also ask

Can I run Unity on 2gb RAM?

Unity can certainly run on 2 – 4GBs of RAM, but it won't be a great experience—especially with 2GBs.

Is Unity good for low end PC?

So it will work as long as u have got 64 bit OS. Just for latest versions. If you have 32 bit OS, then still unity will work just the version till 5.6 and not further ones. Thank you!

Is 4GB RAM enough for Unity?

Though you can run many apps(5 apps before ram issues start), 4GB ram isn't enough to run both Unity and VS studio.


2 Answers

Unity has a configuration API so it's pretty easy to write some auto-configuration code using reflection.

Several people have blogged about it here:

http://geekswithblogs.net/watsonjon/archive/2009/09/28/unity-convention-based-registration.aspx

http://geekswithblogs.net/brians/archive/2010/07/04/convention-based-registration-extension-for-the-microsoft-unity-ioc-container.aspx

Including this one with some framework code you can reuse:

http://thedersen.com/2011/02/20/convention-based-configuration-for-microsoft-unity/

This has been discussed on the Unity discussion board. The issue is that everyone wants different conventions. Look at the blog posts, writing your own seems pretty trivial.

like image 184
Ade Miller Avatar answered Oct 12 '22 23:10

Ade Miller


In unity 3.0 you can now do configuration by convention. This blog post explains it in more detail:

http://blogs.msdn.com/b/agile/archive/2013/03/12/unity-configuration-registration-by-convention.aspx

like image 37
Ross Dargan Avatar answered Oct 13 '22 01:10

Ross Dargan