servicestack,protobuf-net,C#,servicestack,Protobuf Net" /> servicestack,protobuf-net,C#,servicestack,Protobuf Net" />

C# 如何在ServiceStack中添加protobuf

C# 如何在ServiceStack中添加protobuf,c#,servicestack,protobuf-net,C#,servicestack,Protobuf Net,我正在尝试将protobuf添加到基于ServiceStack的web项目中。但以下两种方法都存在错误 Global.asax.cs 如何在项目中启用ProtoBuf格式?由于您没有提到遇到的错误,请首先确保已添加了 然后,您只需添加ProtoBufFormat插件,但ServiceStack插件的所有configuration inc.注册必须在AppHost.Configure方法中进行,因此请尝试: public class AppHost { ... public void

我正在尝试将protobuf添加到基于ServiceStack的web项目中。但以下两种方法都存在错误

Global.asax.cs


如何在项目中启用ProtoBuf格式?

由于您没有提到遇到的错误,请首先确保已添加了

然后,您只需添加ProtoBufFormat插件,但ServiceStack插件的所有configuration inc.注册必须在AppHost.Configure方法中进行,因此请尝试:

public class AppHost
{
   ...

   public void Configure(Container container)
   {
       Plugins.Add(new ProtoBufFormat());
   }
}

通过向项目中添加webactivator框架,我不知何故找到了答案,因为较新的ServiceStack.Plugins.Protobuf删除了它;我使用旧的ServiceStack.Plugins.Protobuf版本重新添加了它@mythz@jeff由于它是1-less依赖关系,我宁愿自己避免WebActivator,无论哪种方式,您都只需要在启动时使用新的AppHost.Init;,初始化ServiceStack;,在Global.asax/Application\u Start中或使用WebActivator。我不知道为什么在使用插件的最新ServiceStack.Plugins.ProtoBufFormat.Addnew ProtoBufFormat或ServiceStack.Plugins.Protobuf.AppStart.Start时无法解析依赖项。@jeff the Plugins.Addnew ProtoBufFormat;在AppHost.Configure中,而不是在构造函数中。
public class AppHost
{
   ...

   public void Configure(Container container)
   {
       Plugins.Add(new ProtoBufFormat());
   }
}