locked
Moving from Visual Studio 2005 to VS 2008 to VS 2010 (easy question) RRS feed

  • Question

  • User686339638 posted

    I bought a book to help me learning WCF. Lots of people complained that the book was written for VS 2005 at first then there was a reprinting for VS 2008.  What it seems is that the code for VS 2005 would not work in VS 2008.  I'm wondering why?  What is more likely the solution files or the code itself? 

    I know that code gets deprecated (methods and even whole classes). I"m wondering what are the chances that what i learn in the book from 2008 will work in VS 2010. I assume that I shouldn't have to RE-LEARN WCF for each version of Visual Studio.

    I wanted to get some thoughts on this before i spend time learning something I can't use.  Thanks!

    Thursday, September 19, 2013 1:25 PM

Answers

  • User252092379 posted

    It's normal sometimes there are big changes from a framework version to another. For instance, when the Razor was added to MVC 3, however only the sintax to create Views was need to "re-learn".

    Normally the concept does not change, but part of how something should be done changes.

    In the case of Visual Studio, new functionality and features are added with each new version. The project structure also changes, but when you open a project from a previous version to a new version, usually Visual Studio converts the project.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 19, 2013 3:20 PM
  • User686339638 posted

    I fixed this problem by adding a Reference to the Assembly for System.ServiceModel, but I'm still getting an error.

    HTTP could not register URL http://+:8000/HelloIndigo/. Your process does not have access rights to this namespace (seehttp://go.microsoft.com/fwlink/?LinkId=70353 for details).

    It is crashing on host.Open();

    The followed the advice found here: http://blogs.msdn.com/b/amitlale/archive/2007/01/29/addressaccessdeniedexception-cause-and-solution.aspx

    But it did not work.

    It said to do something like this and I was able to successfully add it. But it didn't work.

    netsh http add urlacl url=http://+:8000/HelloIndigo user=Sam

    I had to also close Visual Studio and restart it as administrator. Then the code worked.

    The code in the console project looks like this:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.ServiceModel;
    
    namespace Host
    {
        class Program
        {
            static void Main(string[] args)
            {
                using (ServiceHost host = new ServiceHost(typeof(HelloIndigo.HelloIndigoService), new Uri("http://localhost:808/HelloIndigo")))
                {
                    host.AddServiceEndpoint(typeof(HelloIndigo.IHelloIndigoService), new BasicHttpBinding(), "HelloIndigoService");
                    host.Open();
                    Console.WriteLine("Press < ENTER > to terminate the service host"); Console.ReadLine();
                }
            }
    
        }
    }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, September 20, 2013 12:59 AM

All replies

  • User252092379 posted

    It's normal sometimes there are big changes from a framework version to another. For instance, when the Razor was added to MVC 3, however only the sintax to create Views was need to "re-learn".

    Normally the concept does not change, but part of how something should be done changes.

    In the case of Visual Studio, new functionality and features are added with each new version. The project structure also changes, but when you open a project from a previous version to a new version, usually Visual Studio converts the project.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 19, 2013 3:20 PM
  • User686339638 posted

    When i open the files i downloaded as you said VS2010 tries to convert it. I've not tried that yet.  (OK I converted it and it still doesn't work. Hopefully when i install VS2008, it will)  Tomorrow I will try to reinstall VS2008. Obviously the code as stated in the book even for this simple service doesn't work.

    The author told us to add an Empty solution. So i did. I'm using VS2010. Then Add a Class Library. So I did. While I'm not getting squiggly lines, it does not recognize using System.ServiceModel;. When i compile i get the error messages down below even though it doesn't do squiggly lines. 

    This is all the code I have. I assume the author is using the wrong library maybe? I followed the instructions

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.ServiceModel;
    
    namespace HelloIndigo
    {
        [ServiceContract(Namespace = " http://www.thatindigogirl.com/samples/2006/06")]
        public interface IHelloIndigoService
        {
            [OperationContract]
            string HelloIndigo();
        }
    
        public class HelloIndigoService : IHelloIndigoService
        {
            public string HelloIndigo()
            {
                return "Hello Indigo";
            }
        }
    }

    I get these errors:

    Error 1 Program 'c:\users\documents\visual studio 2010\projects\ServiceFromScratch\ServiceFromScratch\obj\x86\Debug\ServiceFromScratch.exe' does not contain a static 'Main' method suitable for an entry point ServiceFromScratch

    Error 2 The type or namespace name 'ServiceModel' does not exist in the namespace 'System' (are you missing an assembly reference?) c:\users\documents\visual studio 2010\projects\ServiceFromScratch\HelloIndigo\Service.cs 5 14 HelloIndigo

    Error 4 The type or namespace name 'ServiceContractAttribute' could not be found (are you missing a using directive or an assembly reference?) c:\users\keoki stevenson\documents\visual studio 2010\projects\ServiceFromScratch\HelloIndigo\Service.cs 11 6 HelloIndigo

    Thanks!

    Thursday, September 19, 2013 9:50 PM
  • User686339638 posted

    I fixed this problem by adding a Reference to the Assembly for System.ServiceModel, but I'm still getting an error.

    HTTP could not register URL http://+:8000/HelloIndigo/. Your process does not have access rights to this namespace (seehttp://go.microsoft.com/fwlink/?LinkId=70353 for details).

    It is crashing on host.Open();

    The followed the advice found here: http://blogs.msdn.com/b/amitlale/archive/2007/01/29/addressaccessdeniedexception-cause-and-solution.aspx

    But it did not work.

    It said to do something like this and I was able to successfully add it. But it didn't work.

    netsh http add urlacl url=http://+:8000/HelloIndigo user=Sam

    I had to also close Visual Studio and restart it as administrator. Then the code worked.

    The code in the console project looks like this:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.ServiceModel;
    
    namespace Host
    {
        class Program
        {
            static void Main(string[] args)
            {
                using (ServiceHost host = new ServiceHost(typeof(HelloIndigo.HelloIndigoService), new Uri("http://localhost:808/HelloIndigo")))
                {
                    host.AddServiceEndpoint(typeof(HelloIndigo.IHelloIndigoService), new BasicHttpBinding(), "HelloIndigoService");
                    host.Open();
                    Console.WriteLine("Press < ENTER > to terminate the service host"); Console.ReadLine();
                }
            }
    
        }
    }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, September 20, 2013 12:59 AM