Yortw / RSSDP

Really Simple Service Discovery Protocol - a 100% .Net implementation of the SSDP protocol for publishing custom/basic devices, and discovering all device types on a network.

Home Page:http://yortw.github.io/RSSDP/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Installing the Nuget package in a new Android project does not add correct references

martinwiboe opened this issue · comments

We have been using the 2.0.0.1 version of RSSDP, installed through Nuget, and it worked flawlessly. However, the project cannot be built after installing the newest version (3.0.2).

When building the project, the following error occurs:

The type 'SsdpDeviceLocator' is defined in an assembly that is not referenced. You must add a reference to assembly 'Rssdp.Native, Version=3.0.2.0, Culture=neutral, PublicKeyToken=null'.

This also occurs when adding the package in an empty project. I have created a small repro project: https://www.dropbox.com/s/thft4y00frnw1pu/DlnaPlayground.7z?dl=0

Thank you for reporting this issue.

I have found the problem. Between the update to support Net Standard 1.3 (now used in place of Xamarin iOS/Android specific binaries) and the update to support the bait and switch technique, something got missed. Specifically the netstandard assembly had a name incompatible with the bait and switch technique. Both of these features were PR's from other devs, and I guess I missed the assembly name issue when merging them, especially since the code works when B&S is not needed.

This would only affect projects where there was a PCL using RSSDP is linked from a head project using the net standard assembly. Installing directly into the head Android project would have been fine if no PCL was in use. The sample project you submitted was the perfect example of the actual problem, so thanks heaps for providing that.

I have published package version 3.0.3 which should fix this. Please confirm one way or the other once you've had a chance to try it.

One further note - because of the change in assembly name, the dll file has also changed. If you have any sort of manual deployment/script that gathers specific files you'll want to make sure rssdp.native.dll is deployed and not the old rssdp.netcore.dll.

Thanks for responding so quickly, @Yortw! The updated package appears to fix most of the build errors in our projects, with the exception of a console application that references the net45 version of Rssdp.Native. When building this, compilation fails with the error message:

The type 'SsdpRootDevice' is defined in an assembly that is not referenced. You must add a reference to assembly 'Rssdp.Portable, Version=3.0.3.0, Culture=neutral, PublicKeyToken=null'.

Additionally, the new version of the library causes an error when running on my phone (OnePlus 3). When calling locator.SearchAsync(TimeSpan.FromSeconds(20)) from code in a PCL project, the app quits with a non-managed exception and the output shows

05-10 11:01:53.149 F/        (11244): Rssdp.Infrastructure.SsdpCommunicationsServer doesn't implement interface Rssdp.Infrastructure.ISsdpCommunicationsServer
05-10 11:01:53.149 F/libc    (11244): Fatal signal 6 (SIGABRT), code -6 in tid 11244 (en.OneApp.debug)

I'm not sure if this is related to this issue. Let me know if you'd like me to create a new issue :) Thanks.

Hi,

First, apologies for the frustration this must be causing you!

With regards the .Net 4.5 console app, I am not able to reproduce this. I created a new console app targeting .Net 4.5 and installed the latest package, wrote some code to perform a search, and it runs fine, returning 69 devices. Can you provide a project to reproduce this issue? If so then I have a better chance of fixing it. Thanks.

As for the Android project, I've spent a couple of hours on it and the problem appears to be the .Net Standard library now used to support Xamarin projects is not compatible with the bait & switch technique, so can't be used in PCL based solutions. There appear to be two possible solutions but I have not yet determineed which is best/right and I won't have more time to look until tonight at the earliest. The possible solutions are;

  • Abandon the .Net Standard library for any platforms that aren't themselves .Net Standard/.Net core. Instead reinstate the per platform 'head' projects and go back to doing the bait & switch pattern explicitly for each platform. If I'm going to do this I might as well clean the library up and implement B&S so there is only a single assembly for each platform, rather than the common PCL + native dll for each.

  • Drop the bait & switch entirely. While the Net Standard assembly can't successfully reference the PCL, the reverse does seem to work. So in your case the Nuget package would add the .Net Standard assembly as a reference to your PCL project instead. The problem here is that I'm not sure exactly which PCL profiles overlap with .Net Standard 1.3 or if there are any other issues I'm not aware of. However this is considerably less work on my part and allows us to keep using the newer tech.

As a temporary work around, you may be able to fix your Android project by manually;

  • Removing all the RSSDP references in the PCL project
  • Add a single reference to the packages\Rssdp.3.0.3\lib\netstandard13\Rssdp.Native.dll assembly

No apologies necessary :) We benefit a lot from using RSSDP in our app, so thanks for that!

I can't reproduce the console app issue in a clean project, so I guess it is caused by the PCL reference and is not a separate problem.

With regards to your proposed solutions, I'm not really sure which one is the best. I'd be happy to test whatever solution you come up with and provide feedback.

Fixing our Android project doesn't really help since most of our functionality resides in the PCL. We'll stay on 2.0.0.1 for a bit longer.

I've gone with option #1 as I need to continue .Net 4.0 support and I don't believe that's possible with Net Standard anything.

There should be a pre-release package in Nuget now, v3.5.0, that has these changes in it. I tested it in the Android PCL solution you provided for testing previously and it seems to work. I'll need more time to test it on the other platforms before making it an official release, but it appears to work for .Net 4.0 as the tests/samples project also works.

Please let me know if this works for you.

The new version of the package works well. I've tested in a solution with Android, PCL and Console projects. All are fine 👍

Excellent, thanks Martin. If I get time tonight I'll test it with some other project types/environments. Hope to release soon, but you should be safe using that package in the meantime, the only changes in it are to make it PCL compatible.

Thanks, great work!

Just published a new official release package which should contain these fixes. Please close this issue if that package works for you.
Thanks.