Running External Application in a Microsoft::VisualStudio::CppUnitTestFramework Test

Iman Biglari 0 Reputation points
2023-10-04T01:28:23.9333333+00:00

I am writing a test project for an MFC application using Microsoft::VisualStudio::CppUnitTestFramework, with a single step to verify end-to-end integration of the said application with all external parties (SQL Server and other entities). I need to start and control a number of external processes this MFC application will communicate with. One of these external applications uses dot NET framework v4.0.30319. When I try to start this utility using either ShellExecute() or CreateProcess(), it fails with the below message:

Could not load file or assembly 'Microsoft.VisualStudio.CodeCoverage.Shim, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.

This is despite the fact that I can run the utility from command line directly, and can start other applications from the test project such as Windows Calculator or Notepad. To me, it seems like this dot NET application somehow detects the test environment, and wants to participate in it. If this is true, how can I prevent it? I just need to have this application (and quite a few more, all of which are dot NET applications) to run peacefully.

Developer technologies | C++
Developer technologies | C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
Developer technologies | Visual Studio | Other
Developer technologies | Visual Studio | Other
A family of Microsoft suites of integrated development tools for building applications for Windows, the web, mobile devices and many other platforms. Miscellaneous topics that do not fit into specific categories.
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Zhengye Xu-MSFT 95 Reputation points Microsoft External Staff
    2023-10-04T08:22:05.7333333+00:00

    Hi Iman Biglari,

    Welcome to Microsoft Q&A forum.

    Here are some solutions to try.

    Recreate a new project, and check if this issue appears in this newly created project. Please let me know if it is reproducible.

    If the problem only occurs in a specific project:

    1.Close Visual Studio and delete the .vs folder under the project folder and reopen Visual Studio to build the project.

    2.Reinstall assembly Microsoft.Visual Studio.CodeCoverage.Shim

    If this problem occurs in other projects, you can try repairing Visual Studio using the Visual Studio installer.

    If the problem is still not resolved, you can set MSBuild build output verbosity to verbosity to get more detailed build information and errors.

    Best Regards,

    Zhengye


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    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' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.