Runtime Error with multiple targeting .NET frameworks

Plagapong 1 Reputation point
2020-09-01T13:54:02.897+00:00

Hello Microsoft Team,

I starting some PoC C# projects (Windows 10 & VS2019) I would like to create Windows Service application with underlying multiple target .NET frameworks (.Net Core3.1.Net Standard2.0 and .Net framework4.8)
as shows in diagram below:
21933-poc-01.png

It was able to successfully compiled and built but once Windows Service Started and calling .Net stanadard assembly

Then I'm facing two issues

Issue#1, When Windows Service process start and calling .Net Standard assembly It throws exception error

System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.2.2.0' or one of its dependencies

Then I tried overcome it by changing Assembly Binding configuration in .net48 project and it seems workig well.
And then I re-started the whole process again and facing another issue

System.BadImageFormatException: Could not load file or assembly 'System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.

At this point I'm not quite sure that the component structure above is a valid idea anymore, Could you please help confirm.
And even if it valid, How can we manage to referrence System.Runtime assembly across multiple targeting framework project?

Issue #2, After I reviewed the code I found something strange there were multiple errors in (2) .NET stadard project
21951-poc-02.png

even I got an error above but somehow the project still be able to succesfully compiled I think
this may link with the runtime issue above If your team could help clarify it would be helpful for me.

If you need any further detail please let me know.

Best regards,

---------------------

Edited:
I can't add the right question tag, any tag I try to put in after submit the edit it always turn to "windows-uwp-rutime" :(

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
23,871 questions
No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Fay Wang - MSFT 5,121 Reputation points
    2020-09-02T05:49:03.433+00:00

    Hello,

    Welcome to Microsoft Q&A!

    Currently, Microsoft Q&A supports the products listed over here: supported topics (more to be added later on).

    Your question about Windows Service is not supported yet now.

    Thanks.

    No comments

  2. Plagapong 1 Reputation point
    2020-09-02T06:27:04.387+00:00

    Hi Faywang,

    Thanks for your respond may I ask where is the right place to ask the question ?
    Is it MSDN forum ?

    Best regards