Could not load file or assembly on MCRTEXE.CPP When trying to Debug on C++ CLR Console app

NEP 21 Reputation points
2022-07-08T00:03:29.973+00:00

HI, I have written a C++ CLR console app in VS2019, add reference to a DLL (Microsoft.Sharepoint dll) and was able to build/rebuild the project with no error. I am able to access all the methods or classes inside the dll files in my code but whenever I try to debug or run the program I get the error saying that the system cannot find the dll file.

The error happens inside the MCRTEXE.cpp (which is not even part of my program) from which I understand is a C source file used by the system to set the environment of your project (I'm not sure of this one lol).

Here's the error message:

System.IO.FileNotFoundException: 'Could not load file or assembly 'Microsoft.SharePoint.Library, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The system cannot find the file specified.'

218669-sharepointdll-error.png

I checked and can say that the dll are in the project directory so I'm not sure why it keeps on saying that it cannot find the file.

I'm sure I'm missing on some configuration but I was hoping you could point it to me as I'm fairly new to C++.

Thanks in advance!

Microsoft 365 and Office | SharePoint | Development
Developer technologies | Visual Studio | Debugging
Developer technologies | C++
Developer technologies | Visual Studio | Other
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. RLWA32 49,541 Reputation points
    2022-07-08T01:20:38.003+00:00

    I checked and can say that the dll are in the project directory so I'm not sure why it keeps on saying that it cannot find the file.

    The assembly should be in the same folder that contains your executable. To assist you in resolving these kinds of problems you can use this tool fuslogvw-exe-assembly-binding-log-viewer

    0 comments No comments

  2. NEP 21 Reputation points
    2022-07-13T03:19:27.68+00:00

    Turns out it's an issue with the Sharepoint dll itself, I tried using the Sharepoint.Client dll and Sharepoint.Client .Runtime dll and the error disappears and I am now able to proceed.

    0 comments No comments

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.