Mono 3.4.0上的ServiceStack.Text反射问题

时间:2014-07-01 18:15:16

标签: c# mono servicestack servicestack-text

我在Mono 3.4.0上运行ServiceStack API(4.0.22)并在自托管应用程序上使用异步Web服务,我收到以下错误:

{
    ResponseStatus: {
        ErrorCode: "ArgumentNullException",
        Message: "Argument cannot be null. Parameter name: methodInfo",
        StackTrace: " at System.Reflection.Emit.ILGenerator.EmitCall (OpCode opcode, System.Reflection.MethodInfo methodInfo, System.Type[] optionalParameterTypes) [0x0000c] in /Volumes/build-root-ramdisk/mono-3.4.0/mcs/class/corlib/System.Reflection.Emit/ILGenerator.cs:822 at ServiceStack.Text.FastMember.TypeAccessor.WriteSetter (System.Reflection.Emit.ILGenerator il, System.Type type, System.Reflection.PropertyInfo[] props, System.Reflection.FieldInfo[] fields, Boolean isStatic) [0x00000] in <filename unknown>:0 at ServiceStack.Text.FastMember.TypeAccessor.CreateNew (System.Type type) [0x00000] in <filename unknown>:0 at ServiceStack.Text.FastMember.TypeAccessor.Create (System.Type type) [0x00000] in <filename unknown>:0 at ServiceStack.TaskExt.GetResult (System.Threading.Tasks.Task task) [0x00000] in <filename unknown>:0 at ServiceStack.Host.Handlers.ServiceStackHandlerBase+<>c__DisplayClass6.<HandleResponse>b__4 (System.Threading.Tasks.Task task) [0x00000] in <filename unknown>:0 at ServiceStack.AsyncExtensions.Continue[Task] (System.Threading.Tasks.Task task, System.Func`2 next) [0x00000] in <filename unknown>:0 "
    }
}

退货服务是:

    public async Task<FindSleepResponse> Get(FindSleep request)
    {

        var dbSleep = await _sleepRepository.GetByUser(1);

        var sleep = new List<Tribe.Guru.ServiceModel.Types.Sleep> ();
        foreach (var item in dbSleep)
        {
            var pocoSleep = item.ConvertTo<Tribe.Guru.ServiceModel.Types.Sleep> ();
            sleep.Add (pocoSleep);
        }

        var response = new FindSleepResponse { Sleeps = sleep };

        return response;
    }

poco类是:

    [Route("/sleep", "GET")]
    [DataContract]
    public class FindSleep : IReturn<FindSleepResponse>
    {

    }

    [DataContract]
    public class FindSleepResponse
    {
        [DataMember(Name="sleeps")]
        public List<Sleep> Sleeps { get; set; }
    }

    [DataContract]
    public class Sleep
    {
         [DataMember(Name="id")]
         public int Id { get; set; }

         [DataMember(Name="date")]
         public DateTime ActualDateTime { get; set; }

         [DataMember(Name="hours")]
         public double HoursSleep { get; set; }

         [DataMember(Name="quality")]
         public int SleepQuality { get; set; }

         [DataMember(Name="feeling")]
         public int OverallFeeling { get; set; }

         [DataMember(Name="comment")]
         public string Comment { get ;set; }

     }

Selfhost:

/// <summary>
/// The application host for service stack
/// </summary>
public class AppHost : AppHostHttpListenerBase
{
    /// <summary>
    /// Initializes a new instance of the <see cref="Tribe.Guru.Web.AppHost"/> class.
    /// </summary>
    public AppHost() : base("Tribe Guru Web Services", typeof(SleepService).Assembly) { }

    public override void Configure(Funq.Container container)
    {
        SetConfig(new HostConfig { HandlerFactoryPath = "api" });

        //Setup the container injection
        InitialiseStack.Setup (container);

    }
}

我已经在appharbour上将其部署为MVC应用程序,并且在IIS上没有问题,所以它似乎是Mono问题上的Mono或ServiceStack。任何想法,因为我不能为我的生活解决问题是什么?

1 个答案:

答案 0 :(得分:1)

应该是resolved in this commit,它将在now available on MyGet的ServiceStack的下一个v4.0.23 +版本中提供。