Sharing game code between Urho and Urho.Forms-based projects

I've got shared library project in Visual Studio which I'd like to use in Windows Forms and Android/iOS/Windows 8.1 projects. For WinForms I'm using Urho and for mobile I'm using Urho.Forms, as the UI is done using Xamarin.Forms.

It looks like I can't do it that way, because:
When the shared library references Urho.Forms, I have to reference Urho.Forms in my WinForms application - which doesn't work, as it doesn't have to Desktop namespace and desktop initializers.
When the shared library references Urho, I can't share common mobile UI code which uses Urho.Sharp + I'd have type mismatches (same classes from different libraries) in mobile projects.
When the shared library references both, I've got conflict with reference ambiguity.

What can I do to share one codebase on top of UrhoSharp between WindowsForms and Xamarin.Forms applications?

Best Answer

Answers

  • EgorBoEgorBo BYXamarin Team ✭✭✭

    Have you tried to:
    PCL: add Urho.Forms nuget
    Android/iOS: add Urho.Forms nuget
    WinForms: add Urho nuget
    in theory it should work as it uses the bait&switch approach.

  • mrowamrowa USMember

    @EgorBo said:
    Have you tried to:
    PCL: add Urho.Forms nuget
    Android/iOS: add Urho.Forms nuget
    WinForms: add Urho nuget
    in theory it should work as it uses the bait&switch approach.

    Yes, I've finally had time to try it. Works on Android, but on WinForms application got an error:

    The type 'Application' is defined in an assembly that is not referenced. You must add a reference to assembly 'Urho.Forms, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.

    In WinForms it doesn't throw an error on locally referenced Urho classes, like DesktopUrhoInitializer or Application - it throws error on Urho API referenced by PCL - because the PCL references Urho.Forms and not Urho.

Sign In or Register to comment.