Does anyone have a complete and working DI sample for WCF?
Every sample I find just gets me more confused. Does anyone know of a complete and working standalone simple sample that works with the built in stuff?
Maybe once I get a handle of the built in stuff, I can move on to different DI frameworks such as StructureMap or Unity with WCF.
My MVC project is currently using Unity for all its DI.
I recommend this one. I have already used it and it is fully working.
The code download for my book Dependency Injection in .NET contains a full, working example.
However, most of what you'll need to know is explained in this answer: Injecting data to a WCF service
This one is the most straightforward one I've found.
DI with Castle Windsor
Official Site http://docs.castleproject.org/Windsor.WCF-Integration-Facility.ashx
Blog article http://ayende.com/blog/2548/wcf-windsor-integration
Blog article with sample http://mikehadlow.blogspot.com/2008/11/windsor-wcf-integration.html
There is a fully working downloadable sample here on Codeplex. It uses the Unity.WCF NuGet package, so it's really the kind of slam dunk example you are looking for.
Related
I'm a little confused as to what integrated options I have for DI. I see it's pretty straightforward for .net core (for my particular projects), but I don't need to build a cross platform app and don't see the advantage to using core. However, it doesn't look like .net framework applications are still setup with Global.asax and without Startup.cs so does that mean there is no integrated DI option for .net framework 4.7? Do I still need to get a 3rd party solution or is there a way to use the same DI workflow in a .net framework project as is used in a core project?
Dependency Injection is not integrated by default in classic asp.net, you need to add a nuget package to handle DI (only integrated by default in asp.net core).
EDIT: Even though I found out how to do it as explained below, I still ended up going with Autofac because I didn't realize the Microsoft's solution only supports constructor injection, but not property injection.
I found instructions on how to do it here. I know link answers are bad, but I don't have time to do any more than this. If someone else wants to make an answer with full instructions I will mark it.
https://scottdorman.blog/2016/03/17/integrating-asp-net-core-dependency-injection-in-mvc-4/
Also note that if you are not using Owin already, it is not required. You can set it up just the same in Application_Start method of Global.asax. Only change you would need to make is when it references the Startup class in a statement that reflectively gets all the Controller classes, you will need to change that to be the class the code is in (or any other class in your assembly).
I am planning to integrate Mvc.Futures in my project, but am unable to find any official documentation for this library.
Official project page on nuget.org points to old asp.net project page on codeplex and even there is not so clear where information about Futures can be found.
I might be missing something, but would appreciate if anyone can give me pointers to the right place.
Thanks.
This is follow up on my own question:
I haven't found anything else related to Mvc.Futures after i posted this question, so i ended up using T4MVC which seem to get more love from MSFT than the Futures itself (lead developer of this template is MSFT employee David Ebbo).
We are using it quite successfully so far (more than 8 months) and i am pleased with the results.
For better integration with Visual Studio i am using AutoT4MVC extensions which runs the T4 templates on each change in the sections of the MVC app that require rebuild (such as Controllers, Content*, Views etc..)
To sum up - i would suggest that you stay out of Mvc.Futures for now and use T4MVC instead.
Heading for alternative using for prism and di/ioc. mef is skilful framework for prism but not so fast. trying to use autofac for prism because our application infrastructure have to many presentation layer like a web, mobile, tablet(silverlight) and desktop(wpf). mef is not good idea for web(if there is no pluggin operation etc. requirements)
tried mef and autofac together. used aggregate catalog and exposed parts to autofac but it's a not complatetly solution. there is to many problems to be solved. using are together.(prism, prism.mefextensions, prism.autofacextensions and autofac's mefintegration)
using prism.autofacextensions for alternating mef but autofac is not ready to prism i think. tried some alternative projects but not ready. also autofac is not inject import attributed object automatically and not have a scanning tool for directory(export attribute scanner. it's must be coded.) and all prism extensibility must be declared. i think its not ready to use for prism.
is there a any alternative ready to use for prism framework? we must use ioc container for all presentation layers. whats best solution?
Based on my understanding, Unity container supports all the layers you mentioned of ASP.NET Web API, Windows Phone 8, Silverlight and WPF.
In addition, Bootstrapper implementation and any other feature related to PRISM becomes relatively simple to achieve as PRISM already includes the UnityBootstrapper class which implement most of the required functionality.
You can find helpful information for Unity container in the following CodePlex Unity site:
Microsoft Unity Container 3
I hope this helps.
I am thinking of using nHibernate.Burrow in my mvc.net application. However there are several troubling things that I have read and I am hoping to get them sorted out before I embark on the project:
Are there any issues with running .Burrow with mvc.net?
Are there issues with running .Burrow with the 4.0 framework?
How tightly coupled is .Burrow with the nHibernate? I have read several things indicating that I have to use the same version of nHibernate as was used to create the .Burrow binaries.
Any other thoughts that people have?
Yes, you should use Burrow with appropriate NHibernate version. If you want to use it with another one you can try to put assemblyRedirect in web.config file.
And I wouldn't try to use Burrow with MVC. Yes, it has Session magement and some other usefull featrures, but they are tied to ASP.NET Web Forms.
As a base framework for mvc applications I would suggest Sharp Architecture. It has all required binaries and all versions are latest.
I am trying to learn EF 4 and its code only features. I tried the following great articles and was able to make a sample application.
http://blogs.taiga.nl/martijn/2009/11/22/entity-framework-4-0-a-fresh-start-with-demo-application/#reply
http://blogs.msdn.com/efdesign/archive/2009/10/12/code-only-further-enhancements.aspx
But I am looking for a good reference library / website on Code only feature. I tried searching MSDN but couldn't find it.
Please help.
Thanks a lot.
There might not be many of them yet. Code only is still in beta-stage and was not released with Visual Studio 2010 RTM. If you plan to use it in a productive environment you should consider using fluent nhibernate or waiting to the final release.
http://blogs.msdn.com/efdesign/archive/2009/06/10/code-only.aspx
http://blogs.msdn.com/efdesign/archive/2009/10/12/code-only-further-enhancements.aspx
Here is a blog article with fully working sample code in ASP.NET MVC 2 in a tutorial form that shows how to use both EF 4.0 Code First and in conjunction with ASP.NET MVC 2. It discusses advanced features of EF 4.0 Code First such as mapping to existing databases and customizing the standard conventions in EF 4 Code First.
The link: http://theminimalistdeveloper.com/how-to-map-to-existing-databases-in-entity-fr