Runtime Error on multiple targeting .NET frameworks

Hello Microsoft Team,

I starting some PoC C# projects (Windows 10 & VS2019) I would like to create Windows Service application which implementing multiple target .NET frameworks (.Net[Core3.1, .Net Standard2.0 and .Net framework4.8) as shows below:

It was able successfully to compiled and built but once Windows Service Started and calling .Net stanadard assembly module (2) then I’m facing runtime two issues

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

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.

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

It seems I’m having a problem with runtime conflict because I mixed multiple target .NET together.
I did some research but their answer didn’t help much.
So any suggestion/documents/articles to help me understand more about this runtime issue that would help me a lot.

Thank you,

Plagapong

I think you would need to provide much more detail about your code to help diagnose the issue. Ideally, could you provide the actual code?

But, if I understand what you’re trying to do correctly, I think it’s fundamentally impossible. You simply can’t use a .Net Core assembly in a .Net Framework application. (The other way around might work, but it’s not guaranteed.)

1 Like

Hi svick,

Thanks for your comment, Actully just I’d like to know that Is my idea is going to work or not.
Because I cannot find any solid documents/article to proof my fundamental concept about .NET
referrencing when we have to use mixed multiple target frameworks.

The most document I can find is here but it seems didn’t answer my question so far.

.NET Foundation Website | Blog | Projects | Code of Conduct