How to Start from Scratch?

Topics: Developer Forum, Project Management Forum
Aug 20, 2010 at 3:45 AM

I have a new install of Vista Enterprise, MS MVC 1.0 and MVC 2.0 installed, also MSSQL 2008 SP1 SqlExpress, also Visual Studio 2010.

I am attempting to get started with TBH using C#.

I downloaded the latest bits from this site, opened the .sln in Visual Studio and hit [F6] to build. It does not compile, it is looking for 3rd party DLLs and also some Ajax bits that are in a VB project, even though I am supposed to be working in C#. Did many Bing searches and finally found a Subversion repository with lots of stuff, more than is here on Codeplex. I svn-exported everything and tried to make the site run. It does not.There is a version problem with the AjaxControlToolkit for the web site, TBHBLL does not want to compile with 8 messages like "the type or namespace name 'NewsletterEntities' could not be found (are you missing a using directive or an assembly reference?)    C:\src\tbh\trunk\TBHBLL\Newsletters\NewslettersRepository.cs"

 

I would like to get started but cannot seem to get this source to even start from a fresh installation. Can someone point me to a working installation solution? I just want to start an MVC site that can do ecommerce.

 

Thanks.

 

Aug 20, 2010 at 2:34 PM

Are you sure you have the correct download?  You should be using this one for the MVC 1.0 version of the book.  http://thebeerhouse.codeplex.com/releases/view/27519

Also, word of warning, this is a 2008 project, I tried converting it to 2010 myself but certain sections would not work, such as getting to admin/polls.  The majority of the site works when converted to 2010 but I could not figure out how to resolve the few errors that did exist.  I believe the errors are caused by a custom dll (ManagedFusion.Web) that was written by the author that he did not include source code for in the download from this site.  Visual studio is unable to upgrade this code  because well it's just a dll.  But that's just my hunch, I'm just trying to learn MVC myself and am not an expert.

It looks like you can get the code for these custom dll's and then give a go at converting them to 2010 projects & or MVC 2,.0.  I haven't had time to try this myself, but will post back in the future when I have tried.  See this post which tells you about the dll and where to get the source code:

http://p2p.wrox.com/book-asp-net-mvc-website-programming-problem-design-solution-isbn-9780470410950/75932-managed-fusion.html

 

Aug 20, 2010 at 4:57 PM
Edited Aug 20, 2010 at 7:18 PM

Today I found time to give a shot to updating the ManagedFusion dlls to Visual Studio 2010 4.0 projects.  Visual Studio took care of this by itself. 

The only problem I had was within the ManagedFusion.Web project.  The class  DefaultAttribute.cs has the following method.

 

public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
            {
                ValueProviderResult result;
                bindingContext.ValueProvider.TryGetValue(bindingContext.ModelName, out result);

                if (result != null)
                {
                    var culture = result.Culture;
                    var value = result.RawValue;
                    var destinationType = bindingContext.ModelType;

                    if (value != null)
                        return result.ConvertTo(destinationType, culture);
                }

                // try to convert the default to the type of the output
                return Default;
            }

 

The TryGetValue method in the following line:

 

bindingContext.ValueProvider.TryGetValue(bindingContext.ModelName, out result);

 

could not be found so I simply commented out the entire block of code and left a blank method.  I still allow it to return default.  It appears some sort of localization functionality will be lost, but at least it functions.  If I ever find a solution to this problem I will post back.

One more point for converting to 4.0.  You will experience the following error during the post when editing articles or anything that uses the TinyMCE html editor.

a potentially dangerous request.form value was detected from the client

To fix this, in your web.config file add the following config element to your system.web section

 <httpRuntime requestValidationMode="2.0"/>

I found the answer to this problem here http://stackoverflow.com/questions/807662/why-is-validateinputfalse-not-working

 

 

 

Aug 20, 2010 at 8:26 PM

I did a new download to a new directory, this time getting all 3 packages (VB/CS/DB) from this Codeplex site. I unpacked everything, opened the C# solution and did not let VS2010 try to update anything. When I tried to build TBHBLL project, I get this series of errors:

 

Error    1    Error 10016: Error resolving item 'EntityTypeShape'. The exception message is: 'Unresolved reference 'BLL.SiteMapInfo'.'.    C:\src\tbh5\TBHBLL\Navigation\SiteMapModel.edmx    112    112    TBHBLL
Error    2    The type or namespace name 'CalendarofEventsEntities' could not be found (are you missing a using directive or an assembly reference?)    C:\src\tbh5\TBHBLL\Events\BaseEventRepository.cs    10    17    TBHBLL
Error    3    The type or namespace name 'NewsletterEntities' could not be found (are you missing a using directive or an assembly reference?)    C:\src\tbh5\TBHBLL\Newsletters\NewslettersRepository.cs    20    17    TBHBLL
Error    4    The type or namespace name 'NewsletterEntities' could not be found (are you missing a using directive or an assembly reference?)    C:\src\tbh5\TBHBLL\Newsletters\NewslettersRepository.cs    22    16    TBHBLL
Error    5    The type or namespace name 'CalendarofEventsEntities' could not be found (are you missing a using directive or an assembly reference?)    C:\src\tbh5\TBHBLL\Events\BaseEventRepository.cs    27    16    TBHBLL
Error    6    The type or namespace name 'ForumModel' could not be found (are you missing a using directive or an assembly reference?)    C:\src\tbh5\TBHBLL\Forums\BaseForumRepository.cs    28    17    TBHBLL
Error    7    The type or namespace name 'ForumModel' could not be found (are you missing a using directive or an assembly reference?)    C:\src\tbh5\TBHBLL\Forums\BaseForumRepository.cs    29    16    TBHBLL


 

 

 

Aug 23, 2010 at 7:11 PM

What is the URL of the location you are downloading your source code from?   By the looks of it, if you are after the MVC version of the book, you are not getting the right one.  This is what you want....

http://thebeerhouse.codeplex.com/releases/view/27519

Feb 5, 2011 at 12:50 PM

I downloaded the ManagedFusion code and changed the BindModel method so that it no longer uses TryGetValue (which I'm guessing was deprecated from the original System.Web.MVC. My BIndModel method is as follows:

            public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
            {
                try
                {
                    ValueProviderResult result = bindingContext.ValueProvider.GetValue(bindingContext.ModelName);

                    if (result != null)
                    {
                        var culture = result.Culture;
                        var value = result.RawValue;
                        var destinationType = bindingContext.ModelType;

                        if (value != null)
                            return result.ConvertTo(destinationType, culture);
                    }
                }
                catch (Exception)
                {
                }
                // try to convert the default to the type of the output
                return Default;
            }

Hope this helps.