This project is read-only.

Problem when following the code first screencast

May 29, 2012 at 9:54 PM

I find RestfulObjects very interesting and would like to use it in my database project. To understand it  I have been following the code first screen cast and have a technical problem I am hoping you can help me with.

I resolved initial problems using the information in the previous discussion however I then have the error during build

c:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3247: Found conflicts between different versions of the same dependent assembly.

Running an assembly diagnostic program gave me this information

Possible conflicts for System.ComponentModel.DataAnnotations:
EntityFramework references System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
NakedObjects.Helpers references System.ComponentModel.DataAnnotations, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
NakedObjects.Persistor.Entity references System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
NakedObjects.Reflector.DotNet references System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
System.Web.Http references System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
System.Web.Mvc references System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
System.Web.WebPages references System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35

I am using VS2010 SP1, MVC4,

Any help gratefully received

Thanks

Laurie

May 30, 2012 at 8:35 AM

Isn't that just a warning rather than an error ? Does the compile complete and the code execute ?  Or is there some other error ?

Jun 5, 2012 at 11:27 PM

I decided to start again but I am getting different behaviour now

Here is the Nuget log

PM> install-package restfulobjects.server -pre
Attempting to resolve dependency 'NakedObjects.Surface.Nof4 (≥ 0.9.0)'.
Attempting to resolve dependency 'NakedObjects.Framework (≥ 4.1.0)'.
Attempting to resolve dependency 'NakedObjects.ProgrammingModel (≥ 4.1.0)'.
Attempting to resolve dependency 'NakedObjects.Ide (≥ 4.1.0)'.
Attempting to resolve dependency 'log4net (≥ 2.0.0)'.
Attempting to resolve dependency 'EntityFramework (≥ 4.3.1)'.
Attempting to resolve dependency 'NakedObjects.Surface (≥ 0.5.0)'.
Attempting to resolve dependency 'RestfulObjects.Mvc (≥ 0.22.0-beta)'.
Attempting to resolve dependency 'AspNetWebApi (≥ 4.0.20126.16343)'.
Attempting to resolve dependency 'Microsoft.AspNet.WebApi (≥ 4.0.20505.0)'.
Attempting to resolve dependency 'Microsoft.AspNet.WebApi.WebHost (≥ 4.0.20505.0)'.
Attempting to resolve dependency 'Microsoft.Web.Infrastructure (≥ 1.0.0.0)'.
Attempting to resolve dependency 'Microsoft.AspNet.WebApi.Core (≥ 4.0.20505.0)'.
Attempting to resolve dependency 'Microsoft.AspNet.WebApi.Client (≥ 4.0.20505.0)'.
Attempting to resolve dependency 'Microsoft.Net.Http (≥ 2.0.20505.0)'.
Attempting to resolve dependency 'Newtonsoft.Json (≥ 4.5.1)'.
Attempting to resolve dependency 'WebActivator (≥ 1.5)'.
Successfully installed 'NakedObjects.Ide 4.1.0'.
Successfully installed 'NakedObjects.ProgrammingModel 4.1.0'.
Successfully installed 'log4net 2.0.0'.
You are downloading EntityFramework from Microsoft, the license agreement to which is available at http://go.microsoft.com/fwlink/?LinkId=242868. Check the package for additional dependencies, which may come with their own license agreement(s). Your use of the package and dependencies constitutes your acceptance of their license agreements. If you do not accept the license agreement(s), then delete the relevant components from your device.
Successfully installed 'EntityFramework 4.3.1'.
Successfully installed 'NakedObjects.Framework 4.1.0'.
Successfully installed 'NakedObjects.Surface 0.5.0'.
Successfully installed 'NakedObjects.Surface.Nof4 0.9.0'.
Successfully installed 'Microsoft.Net.Http 2.0.20505.0'.
Successfully installed 'Newtonsoft.Json 4.5.6'.
Successfully installed 'Microsoft.AspNet.WebApi.Client 4.0.20505.0'.
Successfully installed 'Microsoft.AspNet.WebApi.Core 4.0.20505.0'.
Successfully installed 'Microsoft.AspNet.WebApi.WebHost 4.0.20505.0'.
Successfully installed 'Microsoft.AspNet.WebApi 4.0.20505.0'.
Successfully installed 'AspNetWebApi 4.0.20505.0'.
Successfully installed 'RestfulObjects.Mvc 0.22.0-beta'.
Successfully installed 'WebActivator 1.5.1'.
Successfully installed 'RestfulObjects.Server 0.16.0-beta'.
Successfully added 'NakedObjects.Ide 4.1.0' to TestfullObjectsAPI.
Successfully added 'NakedObjects.ProgrammingModel 4.1.0' to TestfullObjectsAPI.
Successfully added 'log4net 2.0.0' to TestfullObjectsAPI.
Successfully removed 'EntityFramework 4.1.10331.0' from TestfullObjectsAPI.
Successfully added 'EntityFramework 4.3.1' to TestfullObjectsAPI.
Successfully added 'NakedObjects.Framework 4.1.0' to TestfullObjectsAPI.
Successfully added 'NakedObjects.Surface 0.5.0' to TestfullObjectsAPI.
Successfully added 'NakedObjects.Surface.Nof4 0.9.0' to TestfullObjectsAPI.
Successfully removed 'AspNetWebApi 4.0.20126.16343' from TestfullObjectsAPI.
Successfully removed 'AspNetWebApi.Core 4.0.20126.16343' from TestfullObjectsAPI.
Successfully removed 'System.Net.Http.Formatting 4.0.20126.16343' from TestfullObjectsAPI.
Successfully removed 'System.Net.Http 2.0.20126.16343' from TestfullObjectsAPI.
Successfully added 'Microsoft.Net.Http 2.0.20505.0' to TestfullObjectsAPI.
Successfully added 'Newtonsoft.Json 4.5.6' to TestfullObjectsAPI.
Successfully added 'Microsoft.AspNet.WebApi.Client 4.0.20505.0' to TestfullObjectsAPI.
Successfully added 'Microsoft.AspNet.WebApi.Core 4.0.20505.0' to TestfullObjectsAPI.
Successfully added 'Microsoft.AspNet.WebApi.WebHost 4.0.20505.0' to TestfullObjectsAPI.
Successfully added 'Microsoft.AspNet.WebApi 4.0.20505.0' to TestfullObjectsAPI.
Successfully added 'AspNetWebApi 4.0.20505.0' to TestfullObjectsAPI.
Successfully added 'RestfulObjects.Mvc 0.22.0-beta' to TestfullObjectsAPI.
Successfully added 'WebActivator 1.5.1' to TestfullObjectsAPI.
Successfully added 'RestfulObjects.Server 0.16.0-beta' to TestfullObjectsAPI.
Successfully uninstalled 'EntityFramework 4.1.10331.0'.
Successfully uninstalled 'AspNetWebApi 4.0.20126.16343'.
Successfully uninstalled 'AspNetWebApi.Core 4.0.20126.16343'.
Successfully uninstalled 'System.Net.Http.Formatting 4.0.20126.16343'.
Successfully uninstalled 'System.Net.Http 2.0.20126.16343'.

 

Compile gives error

Error 1 The type or namespace name 'IDependencyResolver' does not exist in the namespace 'System.Web.Http.Services' (are you missing an assembly reference?)

Through the object browser System.Web.Http.Services does not implement 'IDependencyResolver'.

System.Web.Http.Dependencies does  implement 'IDependencyResolver'  but using that gives many other compile errors and I am not competent enough to understand where to go next!

I am using VS2010 SP 1, with MVC4 installed. I am using an empty MVC4 project.

I have been using Naked Objects very successfully, but I was hoping to migrate onto RestfulObjects.

Thanks for any help you can offer

Laurie

 

 

 

Jun 6, 2012 at 9:09 AM

It looks like you have the latest ASP.NET MVC RC installed. I'm afraid the current Restful Objects packages are not compatible with that build.

However I'm working on it right now and will get new packages pushed out ASAP (I'm expecting by Friday  8th June).

 

Jun 6, 2012 at 9:32 AM
Edited Jun 6, 2012 at 9:32 AM

Just to add to what Stef said, Laurie  -  Microsoft only announced the RC on Friday, and we have had two days' public holiday this week (the Queen's Jubilee).  But we're getting Restful Objects to work with the RC is now our top priority and we hope to have it done by the end of this week.  We had previously been experimenting with some of the Microsoft nightly-builds, so we've had some chance to prepare and the change shouldn't be a big issue.

Jun 6, 2012 at 9:47 PM

Thanks very much for the info, my sympathies! I look forward to your next release with great interest

Laurie

 

Jun 7, 2012 at 3:05 PM

I've just pushed out 0.17.0 (note that this is no longer an explicit prerelease version and so should be visible in the Nuget package viewer). This is built on ASP.NET MVC4 RC and the associated Web API packages.

Laurie, do please let me know if you have any problems with this release.

 

Jun 7, 2012 at 4:07 PM
Great stuff.
Tnx
Jun 7, 2012 at 9:56 PM

Thanks for your sterling effort. Some feedback after following your tutorial

Created class project with simple repository, installed NuGet NakedObjects.ProgrammingModel, compiles OK.

Added empty MVC4 project, installed NuGET Package Restful Objects Server (Beta). Did nothing else. Compile gives error

Error 1 The type 'System.Web.Http.RouteParameter' exists in both 'c:\Users\laurie\Documents\Visual Studio 2010\Projects\model\packages\System.Web.Http.Common.4.0.20126.16343\lib\net40\System.Web.Http.Common.dll' and 'c:\Users\laurie\Documents\Visual Studio 2010\Projects\model\packages\Microsoft.AspNet.WebApi.Core.4.0.20505.0\lib\net40\System.Web.Http.dll' c:\users\laurie\documents\visual studio 2010\Projects\model\RestfulObjectsAPI\Global.asax.cs 29 38 RestfulObjectsAPI

Then just created a new simple MVC4 empty project, installed NuGET Package Restful Objects Server (Beta). Did nothing else. Compile gives same error.

I don't know how to resolve this!

Laurie

 

Jun 8, 2012 at 9:34 AM
Edited Jun 8, 2012 at 9:36 AM

I'm confused as to why you have a reference to the 'System.Web.Http.Common' package. This is an old package from the previous release of MVC.

When you install an empty MVC 4 RC project you should have the following packages in your package.config file.

 <package id="Microsoft.AspNet.Mvc" version="4.0.20505.0" />
  <package id="Microsoft.AspNet.Razor" version="2.0.20505.0" />
  <package id="Microsoft.AspNet.WebApi" version="4.0.20505.0" />
  <package id="Microsoft.AspNet.WebApi.Client" version="4.0.20505.0" />
  <package id="Microsoft.AspNet.WebApi.Core" version="4.0.20505.0" />
  <package id="Microsoft.AspNet.WebApi.WebHost" version="4.0.20505.0" />
  <package id="Microsoft.AspNet.WebPages" version="2.0.20505.0" />
  <package id="Microsoft.Net.Http" version="2.0.20505.0" />
  <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" />
  <package id="Newtonsoft.Json" version="4.5.1" />


If you have references to packages with a version of "4.0.20126.16343" then you are picking up previous MVC packages.
You may want to try reinstalling MVC4 RC.

The final correct set of packages once you've added RestfulObjects.Server should be as follows. If at this point it has added any "4.0.20126.16343" version packages then you've picked up an old version of RestfulObjects.Server - you want "0.17.0".
 

<package id="EntityFramework" version="4.3.1" />
  <package id="log4net" version="2.0.0" />
  <package id="Microsoft.AspNet.Mvc" version="4.0.20505.0" />
  <package id="Microsoft.AspNet.Razor" version="2.0.20505.0" />
  <package id="Microsoft.AspNet.WebApi" version="4.0.20505.0" />
  <package id="Microsoft.AspNet.WebApi.Client" version="4.0.20505.0" />
  <package id="Microsoft.AspNet.WebApi.Core" version="4.0.20505.0" />
  <package id="Microsoft.AspNet.WebApi.WebHost" version="4.0.20505.0" />
  <package id="Microsoft.AspNet.WebPages" version="2.0.20505.0" />
  <package id="Microsoft.Net.Http" version="2.0.20505.0" />
  <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" />
  <package id="NakedObjects.Framework" version="4.1.0" />
  <package id="NakedObjects.Ide" version="4.1.0" />
  <package id="NakedObjects.ProgrammingModel" version="4.1.0" />
  <package id="NakedObjects.Surface" version="0.5.0" />
  <package id="NakedObjects.Surface.Nof4" version="0.9.0" />
  <package id="Newtonsoft.Json" version="4.5.6" />
  <package id="RestfulObjects.Mvc" version="0.23.0" />
  <package id="RestfulObjects.Server" version="0.17.0" />
  <package id="WebActivator" version="1.5.1" />






 

Jun 9, 2012 at 5:46 PM

Hi, I 've re-installed MVC4 and problem has gone.

Thanks for the suggestions,

Laurie

 

 

Jun 10, 2012 at 10:25 PM

Hi,

Now I have spent a bit more time.

 I was getting error

Error 2 'Model.CommentRepository' is inaccessible due to its protection level c:\users\laurie\documents\visual studio 2010\Projects\model\restfulobjectsapi\App_Start\RunWeb.cs 15 57 restfulobjectsapi

and find that I need to specify

using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("restfulobjectsapi")]

To enable my simple model repository (straight copy of your tutorial) to compile with the API MVC4 project

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NakedObjects;
using System.Runtime.CompilerServices; [assembly: InternalsVisibleTo("restfulobjectsapi")]
namespace Model { class CommentRepository { public IDomainObjectContainer Container { set; protected get; } public IQueryable<Comment> AllComments() { return Container.Instances<Comment>(); } public Comment CreateNewComment() { Comment obj = Container.NewTransientInstance<Comment>(); //set up any parameters //Container.Persist(ref obj); return obj; } } }

However when I run debug the following error is thrown during start up

The domain class: Model.CommentRepository must be marked as public so it can be introspected, evidently related to the first problem.

I don't know where to go from here and would appreciate some more help to progress.

Thanks

Laurie

 

 

Jun 11, 2012 at 7:25 AM

The problem is simply (as the message says) that your CommentRepository class is not public, so Naked Objects can't introspect it.  it should be

public class CommentRepository

The fact that when a new class is created it isn't made public by default is one of the more annoying features of C#.  On my Visual Studio I eventually managed to change the default template used within VS so that classes were created public by default  -  but I can't now remember how I did it.  Worth Googling for. 

Jun 11, 2012 at 10:48 PM

Many thanks - don't know how I missed that!