本文介绍了无法在简单的Grapevine服务器示例中加载类型HttpListener的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Grapevine来实现一个简单的C#REST服务器.我在OSX上使用Xamarin Studio.我拉了Grapevine 4.0.0.195作为包装.

I am trying to use Grapevine to implement a simple C# REST server. I am using Xamarin Studio on OSX. I pulled Grapevine 4.0.0.195 as a package.

但是,当我尝试运行在> https://sukona.github.io/Grapevine上给出的示例时/,出现此错误:

However, when I try to run the example given on https://sukona.github.io/Grapevine/, I get this error:

我检查了Grapevine大会,发现确实存在HttpListener.

I inspected the Grapevine assembly and found that HttpListener is indeed present.

这是我的Program.cs:

using System;
using Grapevine.Server;

namespace TestServer
{
    public sealed class MainClass
    {
        public static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            using (var server = new RestServer())
            {
                server.Start();
                Console.ReadLine();
                server.Stop();
            }
        }
    }
}

推荐答案

我也遇到了同样的问题,并发现了与关于ExtendedProtectionSelector提到的Scott Offen(感谢您的出色工作!)相同的响应.

I also ran into the same issue and and discovered the same response as Scott Offen (thank you for your awesome work btw!) mentioned about ExtendedProtectionSelector.

所以我回到了他以前的版本,并且能够使用3.0.1版的葡萄树在xamarin中制作葡萄树

So I went back to his previous version and I was able to make grapevine work in xamarin using grapevine version 3.1.0

它也不会立即可用(我正在为ios构建,如果您遇到与android相同的问题,则为idk).它将给您一些有关日志记录的错误,因此我在他的日志记录代码中到处都进行了Ctrl + F并进行了更改.我几乎注释掉了EventLogger.cs

It wont work right out of the box either( I was building for ios, idk if you would run into the same issues for android). It will give you some errors about logging so I did Ctrl+F everywhere in his code about logging and changed it. I pretty much commented out everything in EventLogger.cs

然后在RESTServer中,无论哪里有EventLogger报告错误,我都将其简单地更改为Console.Writeline以描述调试时的错误.

Then in RESTServer, wherever there was a EventLogger to report the error, i simply changed it to Console.Writeline to describe the error when debugging.

祝你好运!

这篇关于无法在简单的Grapevine服务器示例中加载类型HttpListener的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 20:19