Visual Studio 2015 - Http не существует в пространстве имен System.Runtime.Remoting.Channels.Http; - PullRequest
0 голосов
/ 20 марта 2019

У меня есть 2 проекта в 2 разных экземплярах Visual Studio 2015, использующих одну и ту же версию .NET Framework (4.5.2) с правильно настроенным объектом запуска и первым, который является следующим:

using System.Collections;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Http;
using System.Runtime.Serialization.Formatters;

namespace ExampleRemoting
{
    public class DateTimeServer : MarshalByRefObject, IDisposable
    {
        public DateTimeServer()
        {
            Console.WriteLine("DateTime server activated");
        }

        ~DateTimeServer()
        {
            Console.WriteLine("DateTime server Object Destroyed.");
        }

        public void Dispose()
        {
            GC.SuppressFinalize(this);
        }

        public String MyMethod(String name)
        {
            String strMessage = "Hi " + name + ". Here is the current DateTime: " + DateTime.Now;
            Console.WriteLine(strMessage);
            return strMessage;
        }
    }

    public class Server
    {
        public static void Main()
        {
            HttpChannel channel = new HttpChannel(9999);
            ChannelServices.RegisterChannel(channel);
            RemotingConfiguration.RegisterWellKnownServiceType(
            Type.GetType("ExampleRemoting.DateTimeServer,Listing23.9"), "SayDateTime", WellKnownObjectMode.SingleCall);
            System.Console.WriteLine("press <enter> to exit.");
            System.Console.ReadLine();
        }

        public String MyMethod(String name)
        {
            String strMessage = "Hi " + name + ". Here is the current DateTime: " + DateTime.Now;
            Console.WriteLine(strMessage);
            return strMessage;
        }
    }
}

Я получаю ошибку в строке using System.Runtime.Remoting.Channels.Http; и получаю эту ошибку: Http does not exist in the namespace System.Runtime.Remoting.Channels.Http;

Я скопировал и вставил тот же код после открытия этого проекта: https://github.com/nccgroup/VulnerableDotNetHTTPRemoting/tree/master/C%23-Sample-Project-Client-Server,, и оказалось, что я больше не получаю ошибку. Этот проект также без проблем использовал тот же класс Http.

Есть идеи о том, что здесь происходит?

Большое спасибо.

...