locked
Any way to use 1.5 CTP2 with VS2010 at all? Even manually?

    Question

  • Hey all!

    For various reasons I have clean installed my dev box and it is running Win7 x64 and currently has VS2010 installed. I am maintaining several projects that require the use of the 1.5 CTP2 release services, under .net 3.5 (obviously). I have already taken the steps needed to install the full 1.5 CTP2 under Win7.

    While I understand that the wizard style tooling that normally runs in VS2008 is not available (at least, I think it isn't?) I am hoping that temporarily I can get by with using the command line tools to tide me over till then so I don't need to keep round tripping into the VS2008 VM I keep handy.

    I need to do the normal things...

    • Create a service and the web.config entries to enable it
    • Create or update a service reference in a Silverlight project
    • Create or update a service reference in a WPF project

    Again, command line is OK - I obviously don't need to do this very often.

    Thanks!

    Ken

    Tuesday, January 05, 2010 10:12 AM

Answers

  • Hi,

    - Create service and web.config entries. The wizard to add ADO.NET Data Service item into your project should be there. Use that one. Once that is done change the references from System.Data.Services.. to Microsoft.Data.Services... and in your .svc file change the Factory type to that assembly as well (namespaces should remain the same). In your svc.cs file you can change the parameter to InitializeService to DataServiceConfiguration if you want the new features, but the interface generated there should work as well.

    - Create or update service reference. The really interesting part this does is to generate the client side classes for the service. The other stuff is just VS project maintenance which you don't really need to build and run your application. Again you should be able to use the Add Service Reference in the VS to setup the project and references and such (don't forget to change System.Data.Services.. to Microsoft.Data.Services...). The pre CTP code gen should work with the CTP binaries unless you need to use some of the new features. In that case use the command line utility called "datasvcutil.exe". See this article for details: http://msdn.microsoft.com/en-us/library/dd756369.aspx
    The steps should be very similar for both SL and WPF, the generated code is identical, you just need to add reference to a different Microsoft.Data.Service.Client.dll in your project.

    Thanks,
    Vitek Karas [MSFT]
    • Marked as answer by Soulhuntre Tuesday, January 05, 2010 2:13 PM
    Tuesday, January 05, 2010 11:25 AM

All replies

  • Hi,

    - Create service and web.config entries. The wizard to add ADO.NET Data Service item into your project should be there. Use that one. Once that is done change the references from System.Data.Services.. to Microsoft.Data.Services... and in your .svc file change the Factory type to that assembly as well (namespaces should remain the same). In your svc.cs file you can change the parameter to InitializeService to DataServiceConfiguration if you want the new features, but the interface generated there should work as well.

    - Create or update service reference. The really interesting part this does is to generate the client side classes for the service. The other stuff is just VS project maintenance which you don't really need to build and run your application. Again you should be able to use the Add Service Reference in the VS to setup the project and references and such (don't forget to change System.Data.Services.. to Microsoft.Data.Services...). The pre CTP code gen should work with the CTP binaries unless you need to use some of the new features. In that case use the command line utility called "datasvcutil.exe". See this article for details: http://msdn.microsoft.com/en-us/library/dd756369.aspx
    The steps should be very similar for both SL and WPF, the generated code is identical, you just need to add reference to a different Microsoft.Data.Service.Client.dll in your project.

    Thanks,
    Vitek Karas [MSFT]
    • Marked as answer by Soulhuntre Tuesday, January 05, 2010 2:13 PM
    Tuesday, January 05, 2010 11:25 AM
  • Hey there!

    Thanks for the tips, one more ??? - is the command shown at that link for datasvcutil.exe going to correctly grab the version that will generate the 1.5 CTP2 features?

    Thanks!
    Tuesday, January 05, 2010 11:43 AM
  • Well, I am not sure if your plan worked or not :)

    I generated the service, allowing it to do its thing. Interestingly it generated what looked like a V2 capable service (the below line was there)... 

    config.DataServiceBehavior.MaxProtocolVersion =

     

    DataServiceProtocolVersion.V2;

    Then I swapped out the System.Data.Services and System.Data.Services.Client for the Microsoft equivelents, set them to Copylocal and then commenced updating the service definition.

    using System;
    using System.Collections.Generic;
    using System.Data.Services;
    using System.Data.Services.Common;
    using System.Linq;
    using System.ServiceModel.Web;
    using System.Web;
    using Foobar.Core.Models;
    
    namespace Foobar.Dashboard.Web.Services
    {
        public class DashboardDataService : DataService<FoobarCmsDataEntities>
        {
            // This method is called only once to initialize service-wide policies.
            public static void InitializeService(DataServiceConfiguration config)
            {
                // TODO: set rules to indicate which entity sets and service operations are visible, updatable, etc.
                // Examples:
                // config.SetEntitySetAccessRule("MyEntityset", EntitySetRights.AllRead);
                // config.SetServiceOperationAccessRule("MyServiceOperation", ServiceOperationRights.All);
                config.SetEntitySetAccessRule("*", EntitySetRights.All);
    
                // TODO: set service behavior configuration options
                // Examples:
                config.DataServiceBehavior.AcceptCountRequests = true;
                config.DataServiceBehavior.AcceptProjectionRequests = true;
                config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
            }
        }
    }

    Unfortunately, I get the dreaded The server encountered an error processing the request. See server logs for more details."  when I tried to view the service. Since the data logging is horrible and NOT goign to the event logs that I can see, this leaves me sort of stuck wondering if this worked or not.

    Grrr :)

    Ken
    Tuesday, January 05, 2010 12:36 PM
  • Ok, well it looks liek the bug was unrelated and ado.net data services doesn't like entities with the SQl Server "time" type.

    Yes, seriously.

    Anyway - your answer worked perfectly Vitek, thanks!

    Ken


    Tuesday, January 05, 2010 2:13 PM
  • Hi,

    As for the dreaded error logging - just add "config.UseVerboseErrors = true" to your service init and you should see some reasonable error message. Just don't forget to remove it for production as the error messages might contain information you might not want the users to see.
    As for the "time" type - what is the CLR type of the property? (it depends on how you mapped the SQL type to CLR, EF or LINQ to SQL, or maybe something else).

    Thanks,
    Vitek Karas [MSFT]
    Tuesday, January 05, 2010 3:48 PM
  • It came out as a TimeSpan which a quick web search tells me is a known problem. Interesting!

    Ken
    Tuesday, January 05, 2010 9:48 PM
  • Hi,

    Data service only supports DateTime for now. Maybe you can change it in the mapping from the DB to convert it to DateTime in which case it should work.

    Thanks,
    Vitek Karas [MSFT]
    Wednesday, January 06, 2010 9:49 AM
  • Hi Vitek!

    I apologise in advance for being a real pain in the butt .. but I have hit a brick wall with vs2010

    I am using vs2010 RC with Silverlight 3 and sql2008.

    VS2008 and CTP2 worked just fine .. very simple code.


    I cant get the same simple code to work with vs2010 ..

    I downloaded the new ctp for silverlight 3 and did the following:
    1. Created my simple simple project.
    2. add ADO entities .. worked just fine
    3. Add WCF data service (see below)
    4. Did a build
    5. replaced the system.data.services.client in both reference librarys with the system.data.servives.client that came with the ctp3
    6.build
    7. code bombs out .. null data on results.

    Any suggestions would be really helpful ..

    Frank Patton
    Saturday, March 13, 2010 10:43 PM
  • using

     

     

    System;

    using

     

     

    System.Collections.Generic;

    using

     

     

    System.Data.Services;

    using

     

     

    System.Data.Services.Common;

    using

     

     

    System.Linq;

    using

     

     

    System.ServiceModel.Web;

    using

     

     

    System.Web;

    namespace

     

     

    SQLHomeFour.Web

    {

     

     

    public class WcfDataService1 : DataService< BiscuitEntities >

    {

     

     

    // This method is called only once to initialize service-wide policies.

     

     

    public static void InitializeService(DataServiceConfiguration config)

    {

     

     

    // TODO: set rules to indicate which entity sets and service operations are visible, updatable, etc.

     

     

    // Examples:

    config.SetEntitySetAccessRule(

     

    "*", EntitySetRights.All);

     

     

    // config.SetServiceOperationAccessRule("MyServiceOperation", ServiceOperationRights.All);

    config.DataServiceBehavior.MaxProtocolVersion =

     

    DataServiceProtocolVersion.V2;

    }

    }

    }

    Saturday, March 13, 2010 10:46 PM
  • Hi,

    I'm a bit lost. CTP3 probably means you're trying to use Silverlight WCF Data Services client, right? But the code above is from the server's service. Also if you say "bombs out", what exactly does that mean? (If you get an exception, please post the exact exception plus its callstack if possible).

    Thanks,
    Vitek Karas [MSFT]
    Monday, March 15, 2010 9:34 AM