1iveowl / Simple-Http-Listener-PCL

Simple Http Server PCL for Xamarin Forms
MIT License
39 stars 6 forks source link

SimpleHttpListener v2: System.Reactive.Linq version mismatch #5

Closed falahati closed 8 years ago

falahati commented 8 years ago

Hi again,

When running the following simple code in an empty Console Application:

static void Main(string[] args)
{
    var server = new SimpleHttpServer.Service.HttpListener(TimeSpan.FromSeconds(30));
    server.StartTcpRequestListener(5058).Wait();
    server.HttpRequestObservable.Subscribe(OnRequest);
}

private static void OnRequest(IHttpRequest httpRequest)
{
    // Something
}

I get the following error message:

An unhandled exception of type 'System.IO.FileLoadException' occurred in SimpleHttpListenerTest.exe

Additional information: Could not load file or assembly 'System.Reactive.Linq, Version=2.2.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Needless to say that the required MicrosoftReactive version by this library is 3.0.0, but somehow it seems that the distributed library does target the MicrosoftReactive 2.2.5

1iveowl commented 8 years ago

The Library does not distribute Rx 2.2.5, however between Rx 2.2.5 and Rx 3.0.0 Rx decided to change the namespace. Therefor, if Rx 2.2.5 have been installed earlier it does not automatically get upgrade to Rx 3.0.0 when installing the SimpleHttpListerner library even as SimpleHttpListener library depends on Rx 3.0.0 in fact you often end up with having both libraries installed and this creates a mess.

To ensure that the namespace change works corrently I will suggest that you remove all rx-xxxx nugets and also remove all the new System.Reactive nugets. Please note that you have to delete them in the right order. The Package Manager will help you and report error if a dependancy stands in the way of deletion. Just try delete another one until it works. After you are sure they are all gone add System.Reactive again. This should fix that issue.

Let me know how it works...?

falahati commented 8 years ago

I cant remove Rx nuget packages cuz your library depends on them. Also they are reported as version 3 by package manager. Any way, I remove your library and then Rx packages. Installed Rx first and then your library. Still same.

Also I didnt had any nuget package about Rx before installing your library, so upgrade should not be the problem. And the only version available on Nuget is RX3

1iveowl commented 8 years ago

I can't explain the issues you are having.

As you can see on nuget.org all the Libraries you are using are depending on System.Reactive 3.0.0:

HttpMachine.PCL v1.1.1 have no Dependancies.

You might want to try and removing all the Nugets and install them again manually. This can be done from the Nuget Console: get-package | uninstall-package -removedependencies

Also, when you add the packages again I would also suggest that you do it using the Nuget Console for maximum control over the version you are adding: install-package <packagename> -v <version>

Finally, try and Clean the Solution before you Rebuild All again.

falahati commented 8 years ago

Ok, meanwhile, can you look at this sample project and see if it is alright for you?

SimpleHttpListenerTest.zip

Thanks

1iveowl commented 8 years ago

Sure but it will be tomorrow. It is midnight here now.

falahati commented 8 years ago

Well it seems that the problem is indeed about dll version mismatch. Please take a look at AsmSpy output:

Reference: System.Reactive.Core 3.0.0.0 by SimpleHttpListenerTest 2.2.5.0 by SimpleHttpServer 3.0.0.0 by SocketLite 3.0.0.0 by System.Reactive.Linq 3.0.0.0 by System.Reactive.PlatformServices 3.0.0.0 by System.Reactive.Windows.Threading

Reference: System.Reactive.Interfaces 2.2.5.0 by SimpleHttpServer 3.0.0.0 by SocketLite 3.0.0.0 by System.Reactive.Core 3.0.0.0 by System.Reactive.Linq 3.0.0.0 by System.Reactive.PlatformServices 3.0.0.0 by System.Reactive.Windows.Threading

Reference: System.Reactive.Linq 2.2.5.0 by SimpleHttpServer 3.0.0.0 by SocketLite 3.0.0.0 by System.Reactive.PlatformServices

1iveowl commented 8 years ago

Thanks for the test project and indeed there was a bug. Sorry about that.

I've issues a hotfix to SocketLite and for SimpleHttpListener upgrading them both from 2.0.4 to 2.0.5. Both still as a Profile7 PCL.

If you update to SimpleHttpListener to 2.0.5 it should work now.

Let me know if all is fine now...?

falahati commented 8 years ago

I can confirm that this problem is solved. Thanks