TypeLoadException on HttpServer.Start()
fean opened this issue · comments
First of all thanks for all your work on this nicely written library!
Well, I'm trying to use your HttpServer
class to serve a stream to a local device. Because the .Net HttpListener
class needs elevated rights to run on any specific URL I quickly started looking at alternatives. So that's when I found your implementation.
I implemented IWorkerModule
to handle the requests the way I need. Added it to a ModuleManager
and added that to an instance of HttpServer
. But the moment I call Start()
this System.TypeLoadException
is thrown:
Method 'CreateClient' in type 'Griffin.WebServer.HttpServer' from assembly 'Griffin.WebServer, Version=0.5.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.
For reference here is my startListening()
method:
/// <summary>
/// Start the HTTP request listener.
/// </summary>
public void startListening()
{
//Add the streaming module to the
moduleManager = new ModuleManager();
moduleManager.Add(new HttpStreamingModule());
// Create and start the HTTP server
server = new HttpServer(moduleManager);
server.Start(IPAddress.Any, 54321);
}
Here is my implementation of the IWorkerModule
also:
/// <summary>
/// Server module that handles incoming http requests
/// </summary>
public class HttpStreamingModule : IWorkerModule
{
#region "Unused IWorkerModule methods"
public void BeginRequest(Griffin.WebServer.IHttpContext context) { }
public void EndRequest(Griffin.WebServer.IHttpContext context) { }
#endregion
/// <summary>
/// Handles any incoming client. Prepares the http request and puts the stream in the connected streams.
/// </summary>
/// <param name="context">The http request context.</param>
/// <param name="callback">The async callback, to be called when the operation finishes.</param>
public void HandleRequestAsync(Griffin.WebServer.IHttpContext context, System.Action<IAsyncModuleResult> callback)
{
// Prepping the response headers
context.Response.ContentType = "audio/mp3";
context.Response.StatusCode = 200;
context.Response.StatusDescription = "OK";
context.Response.KeepAlive = true;
// Create a new response stream
context.Response.Body = new System.IO.MemoryStream();
// Put the response stream in the streams list
App.Logic.streaming.streams.Add(context.Response.Body);
// Call the async callback telling the server we are done
callback(new AsyncModuleResult(context, ModuleResult.Continue));
}
}
It's probably just something I forgot or misinterpreted from your DemoServer. Oh, I almost forgot, I'm using the NuGet package for Griffin.WebServer
.
I'm having the exact same problem with the NuGet package.
I was investigating the cause of a problem I have with my C#/Web project, decided to update Griffin.WebServer and now the application doesn't even start. I'm getting the same error as the OP and I installed the package through NuGet as well.
After applying a general update to all my installed packages through NuGet, the problem seems to have been fixed.
Published a new package with has Griffin.Framework as dependency instead of Griffin.Networking. Should take care of all issues.