My C++ .NET Core library works in Windows 10, but not in Windows 11

David McKay 21 Reputation points
2024-01-15T12:35:29.38+00:00

I have a C++ CLR Class Library (.NET). It can be as basic as a single method:

#pragma once

#include <iostream>

using namespace System;

namespace CoreLibraryFails
{
	public ref class Class1
	{
		// TODO: Add your methods for this class here.
	};

}

_declspec(dllexport) bool Test()
{
	std::cout << "Test Works!\n";

	return false;
}

I call it from a C++ Console App:

// AppFails.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>

_declspec(dllimport) bool Test();

int main()
{
    std::cout << "Hello World!\n";

    Test();
}

All of this is from scratch in VS2022, running on Windows 10. The two work fine in Windows 10, but in Windows 11 "Test Works!" is not output, and I get the following error:

Faulting application name: AppFails.exe, version: 0.0.0.0, time stamp: 0x65a51c1aFaulting module name: ucrtbase.dll, version: 10.0.22621.2506, time stamp: 0xac92626eException code: 0xc0000409Fault offset: 0x0009e34bFaulting process id: 0x0x1300Faulting application start time: 0x0x1DA47A932570389Faulting application path: C:\Users\Dev\Documents\Tests\AppFails.exeFaulting module path: C:\Windows\System32\ucrtbase.dllReport Id: 3d3dfd30-1f41-4ce1-bd60-96340b499096Faulting package full name: Faulting package-relative application ID:

It looks like something fundamental between the exe and the dll. Does anyone have any suggestions what might be going on?

Windows for business | Windows Client for IT Pros | User experience | Other
Developer technologies | C++
Developer technologies | .NET | Other
{count} votes

Accepted answer
  1. David Lowndes 2,640 Reputation points MVP
    2024-01-16T14:19:34.9933333+00:00
    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

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.