Can't load assembly because it is a newer runtime problem... but with a twist

Larry Ledden 0 Reputation points
2023-05-16T19:49:56.6433333+00:00

I have to update an old vb.net app built on .net 3.5, so I recreated its environment which includes several 3rd party dlls. Everything works fine on my Win11 Home laptop. However, my Win11 Pro desktop cannot run this app in the VS2019 IDE. It produces the error 'can't load assembly because it is built with a newer runtime than currently loaded'. By looking at the Modules list I can see which DLL is causing the problem. The reference is correctly set for this InteropDLL which is built on .net V2.0.50727. When I Run the IDE, VS2019 builds a modified version of this Interop using .net 4.0.30319. When attempting to load this module, it hits the error.

I can manually replace the InteropDLL in the debug folder with a copy of the originally referenced InteropDLL and can run the EXE. However, if I Start the IDE, it immediately replaces that DLL and I hit the error.

Any suggestion as to what I might try in this situation? The Win11 Home laptop works correctly with an identical copy of the project folder.

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,926 questions
Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,205 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Jiachen Li-MSFT 32,376 Reputation points Microsoft Vendor
    2023-05-19T01:52:27.1033333+00:00

    Hi @Larry Ledden ,

    Try setting "Use specific version" property to "true" in referenced assembly properties.

    Best Regards.

    Jiachen Li


    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.