mhthomas42 (7) [Avatar] Offline
#1
SimpleCommerce solution issue with CommerceWeb -> Sql.dll binding
Hi all, sorry have not had a chance to read all forum yet. Will do soonest.
Meantime....

I noticed in SimpleCommerce solution, VS2010 on W7 x64, in the CommerceWeb project the bin folder holds Ploeh.Samples.Commerce.Data.Sql.dll (& pdb) files. Is this a bug?

(1) In CommerceWeb project settings there appears to be no VS2010 references to CommerceSqlDataAccess project.

(2) Cleaning the CommerceWeb project and refreshing bin folder contents does NOT remove these two files (not sure why).

(3) These files are dated 2009 and if removed the CompositionRoot execution errors, as it needs reference to the Sql assembly. There are many possible reference locations, easily seen with exception trace using:
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLMSoftwareMicrosoftFusion!EnableLog] (DWORD) to 1.

So, in CommerceWeb, I added a project reference to CommerceSqlDataAccess and it resolved the issue. This was a hack.

Anyone have the 'correct' suggestion to fix my issue? Or, can anyone verify/reproduce or point out I might be wrong?

Thank you! smilie
mark.seemann (383) [Avatar] Offline
#2
Re: SimpleCommerce solution issue with CommerceWeb -> Sql.dll binding
I grant that it seems strange.

The purpose was to demonstrate how to use late binding with Poor Man's DI. That's why there's no project reference between those two projects.

Instead of adding a project reference, you could also just compile the CommerceSqlDataAccess project and copy the binaries.

I should have made a little script that does that...
mhthomas42 (7) [Avatar] Offline
#3
Re: SimpleCommerce solution issue with CommerceWeb -> Sql.dll binding
Oh, my bad. Thanks!

I took the SimpleCommerce project as an example, and am building my own from scratch and trying to follow along in the book, changing some stuff to make sure I understand. smilie

The book is great, no need for a script - I just missed this point.
mark.seemann (383) [Avatar] Offline
#4
Re: SimpleCommerce solution issue with CommerceWeb -> Sql.dll binding
It may not be the clearest or most elaborated point in the book smilie
aylmercarson (3) [Avatar] Offline
#5
Re: SimpleCommerce solution issue with CommerceWeb -> Sql.dll binding
can i ressurect this thread by asking: should we then be adding a reference to the data project in the web project? surely not! does it then mean that each time we rebuild the data dll with changes, we need to manually copy this to the web bin folder? all seems very odd and counter-intuitive?

Message was edited by:
aylmercarson
mark.seemann (383) [Avatar] Offline
#6
Re: SimpleCommerce solution issue with CommerceWeb -> Sql.dll binding
Hopefully, you'll find this discussion helpful: http://stackoverflow.com/a/9503612/126014

FWIW, you shouldn't view the SimpleCommerce solution as prescriptive in this regard. The ComplexCommerce solution is a better place to look.
aylmercarson (3) [Avatar] Offline
#7
Re: SimpleCommerce solution issue with CommerceWeb -> Sql.dll binding
wow - that was a quick reply. many thanks, i'll have a look at the complex solution. can i just say though that i think the book is excellent! it has clarified and extended my understanding of these principles greatly.
mark.seemann (383) [Avatar] Offline
#8
Re: SimpleCommerce solution issue with CommerceWeb -> Sql.dll binding
Thanks - please write again if you have further questions.
aylmercarson (3) [Avatar] Offline
#9
Re: SimpleCommerce solution issue with CommerceWeb -> Sql.dll binding
on from the same issue, i was trying to use ninject as a container, via it's nuget package. this creates the NinjectWebCommon class in the App_Start folder in the mvc web app. in it, you register the dependencies,

eg: kernel.Bind<IMyRepository>().To<MyRepository>();

this also needs

DependencyResolver.SetResolver(t => kernel.Get(t), t => kernel.GetAll(t));

however, because MyRepository is located in the Data project, i need a reference to that project in the web app project. no use of a compositionroot project seems to circumvent this. so back to the same problem. it just feels wrong to have to make that reference. and all that converting entities to and from the domain & data layers...i might just flatten things out a bit.
mark.seemann (383) [Avatar] Offline
#10
Re: SimpleCommerce solution issue with CommerceWeb -&gt; Sql.dll binding
In a project like this, and particularly if you can only do explicit registration, you may be better off without a DI Container at all: http://blog.ploeh.dk/2012/11/06/WhenToUseADIContainer.aspx