tag:blogger.com,1999:blog-8879753012890807179.post4011737152122894182..comments2020-01-20T22:21:47.186-08:00Comments on 2010Wave: Walkthrough using Autofac as your IoC Container in an ASP.NET MVC applicationDarren Neimkehttp://www.blogger.com/profile/04138573191558270297noreply@blogger.comBlogger9125tag:blogger.com,1999:blog-8879753012890807179.post-84801692551620565212010-01-06T03:30:26.379-08:002010-01-06T03:30:26.379-08:00Excellent, glad you got it working Akaka.
And tha...Excellent, glad you got it working Akaka.<br /><br />And thanks for helping out Nick! :-)Darren Neimkehttps://www.blogger.com/profile/04138573191558270297noreply@blogger.comtag:blogger.com,1999:blog-8879753012890807179.post-63094287909474031762010-01-05T20:03:07.120-08:002010-01-05T20:03:07.120-08:00Hi Darren,
I have implemented IMessageProvider o...Hi Darren, <br /><br />I have implemented IMessageProvider on SqlMessageProvider. <br /><br />Nick,<br />Yes, I'm using Autofac 1.4 and thanks for your advise to use Autofac 2, but I solve this issue by coding this in c# and then using reflector to see code in VB, now I can solved this issue by this line of code and still using Autofac 1.4<br /><br /> containerBuilder.Register(Of SqlMessageProvider)(Function(c) New SqlMessageProvider(connectionString)).As(Of IMessageProvider)()<br /><br />Now every thing works as expected.<br /><br />Thanks<br />AkakaAkakahttp://www.akachai.netnoreply@blogger.comtag:blogger.com,1999:blog-8879753012890807179.post-11587721652870699962010-01-05T03:48:12.102-08:002010-01-05T03:48:12.102-08:00Akka, it looks like you're using Autofac 1.4 a...Akka, it looks like you're using Autofac 1.4 and the differences in method resolution between C# and VB are biting you. The compiler thinks your Register call is Register(object), but in C# as per Darren's example, this will compile as Register<T>(Func<IContext, T> creator).<br /><br />The good news: this is fixed in Autofac 2 - these methods now have different names (Register for the delegate version, and RegisterInstance for the other one.) Grab the beta from http://autofac.org and you'll be right as rain :)Nickhttps://www.blogger.com/profile/02020072230899910249noreply@blogger.comtag:blogger.com,1999:blog-8879753012890807179.post-46504818424299756232010-01-05T01:53:42.188-08:002010-01-05T01:53:42.188-08:00Hi Akaka, I might struggle with this as I'm no...Hi Akaka, I might struggle with this as I'm not too familiar with VB, but judging by the error message I would say that you should double-check to ensure that your SqlMessageProvider class does implement the IMessageProvider interface? Just as I have done in the code sample:<br /><br />public class SqlMessageProvider : IMessageProviderDarren Neimkehttps://www.blogger.com/profile/04138573191558270297noreply@blogger.comtag:blogger.com,1999:blog-8879753012890807179.post-47374009628688806512010-01-05T00:05:56.211-08:002010-01-05T00:05:56.211-08:00Cool Darren
Do you have sample in VB.net. I tried...Cool Darren<br /><br />Do you have sample in VB.net. I tried this on VB.net but no luck. I've got an error on this line<br /><br />containerBuilder.Register(Function(c) New SimpleAutofacVB.SqlMessageProvider(connectionString)).As(Of SimpleAutofacVB.IMessageProvider)()<br /><br />This is the error message<br />The component 'VB$AnonymousDelegate_0`2[System.Object,SimpleAutofacVB.SqlMessageProvider]' does not support the service 'SimpleAutofacVB.IMessageProvider'.<br /><br />Do you have any idea on this issue.<br /><br />Thanks<br />AkakaAkakahttp://www.akachai.netnoreply@blogger.comtag:blogger.com,1999:blog-8879753012890807179.post-27155626748144958242010-01-02T03:32:37.022-08:002010-01-02T03:32:37.022-08:00Thanks guys... article code snippet updated! :-)Thanks guys... article code snippet updated! :-)Darren Neimkehttps://www.blogger.com/profile/04138573191558270297noreply@blogger.comtag:blogger.com,1999:blog-8879753012890807179.post-42429694832730690252010-01-02T02:52:59.910-08:002010-01-02T02:52:59.910-08:00Ooops! That's indeed an error in the Autofac d...Ooops! That's indeed an error in the Autofac docs - nice spotting Vijay! Fixed now.<br /><br />Darren - nice job on the article :)Nickhttps://www.blogger.com/profile/02020072230899910249noreply@blogger.comtag:blogger.com,1999:blog-8879753012890807179.post-60141861972413535902010-01-02T01:50:45.488-08:002010-01-02T01:50:45.488-08:00Thanks Vijay, I'll have to test that. I was o...Thanks Vijay, I'll have to test that. I was only going by the code that was provided on the Autofac Wiki page - http://code.google.com/p/autofac/wiki/MvcIntegrationDarren Neimkehttps://www.blogger.com/profile/04138573191558270297noreply@blogger.comtag:blogger.com,1999:blog-8879753012890807179.post-58508089365740274142010-01-02T01:15:54.267-08:002010-01-02T01:15:54.267-08:00Cool Darren!
Autofac is indeed the bomb, but I don...Cool Darren!<br />Autofac is indeed the bomb, but I don't think you need both ContainerProvider.EndRequestLifetime(); in EndRequest AND the http module, because they both do the same thing. I could be wrong thoughVijay Santhanamnoreply@blogger.com