views:

389

answers:

2

I have the following Ria Service define:

namespace SilverlightTest.Web
{
    [EnableClientAccess()]
    public class ContactService : LinqToEntitiesDomainService<AdventureWorksEntities>
    {
        public IQueryable<Contact> GetContactSearch(string lastName)
        {
            ContactRepository rep = new ContactRepository();
            return rep.SearchByLastName(lastName);
        }
    }
}

When I compile the solution, my SilverlightTest project does create the SilverlightTest.Web.g.cs file and the appropriate Context objects are created when I look at it. However, when I attempt to import the SilverlightTest.Web namespace to access the Data Context class for the above service, it says it cannot find the Web namespace.

The only difference I can see between what I'm doing and many examples that are out there on the web is that my AdventureWorksEntities data context is located in a separate business object dll. I tried to query the context directly instead of using the Repository Pattern I'm attempting to do and it also isn't work working.

Any ideas? Is it possible to have Ria Services access a separate DLL handling data access or does it HAVE to be in the same project?

+2  A: 

I've been able to put the Ria service in a separate project before, although I do remember having issues. Not sure exactly what it was, but I would check two things: your references and your web.config (in the hosting website). When you add a ria service to a web project it does some things behind the scenes that wire everything up correctly.

Could try adding a service to your web project temporarily and see what it adds.

James Hollister
When I added another service nothing changed. I compared my web.config to a web.config of one of Brad Abrams' tutorial posts and didn't see anything different either.
JamesEggers
And you have a reference to the service project in the web project? Also, there is an option in the silverlight project properties for a Ria Services link. Although, if you're getting a generated web.g.cs file that should already be marked.
James Hollister
I ended up having to include the generated .g.cs file in my project in order for it to recognize in VS2008. Once I did this it started working. You confirmed my more generalized question of "is it even possible" so marking your answer.
JamesEggers
I've had the same problem over and over again using the Navigation Template and Visual Studio 2008. I can't find another other solution beside including the .gs file in the Silverlight project.
Detroitpro
A: 

It seems that Resharper does not recognize the .gs files and their name spaces. If you disable R# or just code without intelisense it works.

Detroitpro