none
How can I share a library between a WCF Service Application and a Universal Windows App (with the ability to use DataContract AND class diagrams)? RRS feed

  • Question

  • It's kind of a strange question but here is my problem:

    I have an Universal Windows App, a shared framework (using a library/shared project) and a WCF Service Application.
    Because I want to include the DataContracts in my framework and using these in my WCF Service Application and in my Universal Windows App I tried a Portable Library with .Net 4.6 and Universal Windows 10 (using ChannelFactory - I know, i could use a proxy, but i don't want to (not important for this problem)).

    The portable library

    The problem:

    It's not possible to use System.Runtime.Serialization, but it can be used in Universal Windows Libraries (I can't add them to the WCF Service Application) and in Portable Libraries with Windows 8.1 and .Net 4.5.1. I think that's a bug.

    I solved this problem using a Shared Project and BAMM new problem.
    I can't use class diagrams (don't know why?) and I also won't use the UML class diagrams because since VS13 it can't generate the Diagram from Code (even if it would be possible - it doesn't update automatically... why???)

    Tuesday, December 15, 2015 2:01 PM

Answers

  • It seems (and i don't know what a Protable Library (Template) is), that Portable Libraries need the Windows Runtime.

    It is so, that Universal Windows Libraries use the Windows Runtime.

    It is so, that WCF does NOT use Windows Runtime.

    Your selected Projects are just incompatible with each other, you need to seperate them from each other in seperate solutions. (Seems like you can't get around either writing the DataContract classes twice or use the ChannelFactory, which i don't see a point in not using. If it is about needing to add code based on the application at hand, you can use partial classes to add what you need, or use Wrappers in your projects to add what you need)


    Please be so kind to close your Threads when you found an answer, these Threads should help everyone with similar issues.
    You can close a Thread via the"Mark as Answer" link below posts. You can mark your own posts as answers if you were not helped out but found a solution, in such a case, please provide the answer.
    Happy coding
    PS: I assure everyone that I did not ever had the desire to offend anyone.

    Tuesday, December 15, 2015 3:19 PM

All replies

  • Please elaborate more on what you can't add where...

    As i understand, you say you are not able to add System.Runtime.Serialization to WCF, which is impossible, cause it is already used in there. It won't work without it.

    (The presented error just tells a different story, that you do not have the System.Runtime.Serialization in your Portable Project. You need to add the System.Runtime.Serialization to the Portable Project. Which resides in the mscorlib.dll, meaning it is there, try the "using System.Runtime.Serialization;" to make it known to the class you want to use the DataContractAttribute on).

    On class diagrams (which should be another Thread/Question), I don't know the exact problem there, but I won't be able to help on that anyways.


    Please be so kind to close your Threads when you found an answer, these Threads should help everyone with similar issues.
    You can close a Thread via the"Mark as Answer" link below posts. You can mark your own posts as answers if you were not helped out but found a solution, in such a case, please provide the answer.
    Happy coding
    PS: I assure everyone that I did not ever had the desire to offend anyone.


    • Edited by MDeero Tuesday, December 15, 2015 3:11 PM
    Tuesday, December 15, 2015 3:04 PM
  • I can't add the System.Runtime.Serialization to a Portable Library (ONLY if it targets Windows 10 (and .Net 4.6)).
    I can't add a Universal Windows Lib./Universal Runtime Com. to a WCF Service Application/normal Class Lib.
    I can't add a class diagram to a Shared Project.
    Tuesday, December 15, 2015 3:12 PM
  • It seems (and i don't know what a Protable Library (Template) is), that Portable Libraries need the Windows Runtime.

    It is so, that Universal Windows Libraries use the Windows Runtime.

    It is so, that WCF does NOT use Windows Runtime.

    Your selected Projects are just incompatible with each other, you need to seperate them from each other in seperate solutions. (Seems like you can't get around either writing the DataContract classes twice or use the ChannelFactory, which i don't see a point in not using. If it is about needing to add code based on the application at hand, you can use partial classes to add what you need, or use Wrappers in your projects to add what you need)


    Please be so kind to close your Threads when you found an answer, these Threads should help everyone with similar issues.
    You can close a Thread via the"Mark as Answer" link below posts. You can mark your own posts as answers if you were not helped out but found a solution, in such a case, please provide the answer.
    Happy coding
    PS: I assure everyone that I did not ever had the desire to offend anyone.

    Tuesday, December 15, 2015 3:19 PM
  • A Portable Library doesn't need the Windows Runtime. It works fine with a Portable Library with Windows 8.1 and .Net 4.5.1 selected.

    I will probably write a wrapper as you suggested. Thanks ^^
    (If I find a other solution I will post it here)

    Tuesday, December 15, 2015 3:26 PM