0
votes

I have very simple C# library (we'll call it myApi.dll) targeted for .NET 2.0 that executes a simple database insertion. I underlying requirements must keep it at .NET 2.0. When I reference myApi.dll in a new a new VS2013 app, also targeting .NET 2.0, it works exactly as programmed.

The problem is when I take myApi.dll over to another project targeted for .NET 4.5, developed in VS2019, it crashes. It's crashing with an error message that says.

"Could not load file or assembly 'Microsoft.Vsa, Version=7.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified."

Both executing programs are on the same machine. The app targeting .NET 2.0 runs myApi.dll fine but the app targeting .NET 4.5 doesn't.

I've reviewed helpful hints like

I thought setting my 4.5 applications App.confg file to mirror this would help but it didn't.

<?xml version="1.0"?>
<configuration>
  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
    <supportedRuntime version="v2.0"/>
  </startup>
</configuration>

Any thoughts as to why the .NET 2.0 can call myApi.dll just fine and the .NET 4.5 app crashes?

1
Because unfortunately you were using an obsolete API, docs.microsoft.com/en-us/dotnet/api/… All such have been removed since .NET Framework 4.0 so you cannot assume the general upgrade path applies to your project.Lex Li
Alright... So running the .NET 2.0 dll in my .NET 4.5 app could be out of the question. But, could I rewrite my app to target .NET 3.5? Would that work? By reading your link docs.microsoft.com/en-us/dotnet/api/… it would appear that it could.Jeff Nichols

1 Answers

0
votes

VS 2019 does not support obsoleted API of .NET 2.0 to 3.5, because it doesn't support .NET Framework before 4.0. Use older version of Visual Studio, such as VS 2015 (with Update 3) for this obsoleted Vsa API usage.

See also this VS 2019 documentation: https://docs.microsoft.com/en-us/visualstudio/releases/2019/compatibility#-visual-studio-2019-support-for-net-development

Visual Studio 2019 Support for .NET Development