Steps to reproduce
- Create a new project following the README exactly (
Sdk="Nice3point.Revit.Sdk/6.2.3", <OutputType>Exe</OutputType>, <Configurations>Debug.R24</Configurations>), referencing:
<PackageReference Include="Nice3point.Revit.Api.RevitAPI" Version="$(RevitVersion).*" />
<PackageReference Include="Nice3point.TUnit.Revit" Version="$(RevitVersion).*" />
<PackageReference Include="Polyfill" Version="11.0.1" PrivateAssets="all" />
- Add the global executor registration exactly as shown in the README:
[assembly: TestExecutor<RevitThreadExecutor>]
- Add the exact
ApplicationTests sample from the README / your own test project:
public sealed class ApplicationSmokeTests : RevitApiTest
{
[Test]
public async Task Create_XYZ_ValidDistance()
{
var point = Application.Create.NewXYZ(3, 4, 5);
await Assert.That(point.DistanceTo(XYZ.Zero)).IsEqualTo(7).Within(0.1);
}
}
- Run
dotnet run -c Debug.R24 (also reproduced with -c Debug.R25; -c Debug.R26 fails separately/earlier with a RevitAPI, Version=26.4.0.0 FileNotFoundException, since the installed Revit 2026 update — RevitAPI.dll file version 26.5.0.55 — is newer than the latest published Nice3point.Revit.Api.RevitAPI package, 2026.4.10).
✔️ Expected Behavior
The test session initializes, InjectApplication() succeeds, and the test runs against the live Application.
❌ Actual Behavior
The first run on this machine succeeded (R24 and R25 both passed cleanly). Every run since — including after a full machine reboot — fails deterministically in BeforeTestSession with:
TUnit.Core.Exceptions.BeforeTestSessionException: BeforeTestSession hook failed: Attempted to write protected memory.
at TUnit.Engine.Services.HookExecutor.ExecuteBeforeTestSessionHooksAsync(CancellationToken cancellationToken)
at TUnit.Engine.TestExecutor.EnsureTestSessionHooksExecutedAsync(CancellationToken cancellationToken)
at TUnit.Engine.TestExecutor.ExecuteAsync(AbstractExecutableTest executableTest, TestInitializer testInitializer, CancellationToken cancellationToken, Nullable`1 testTimeout)
---> System.InvalidOperationException: Attempted to write protected memory.
at Nice3point.Revit.Injector.Injector.InjectApplication()
at Nice3point.TUnit.Revit.RevitApplicationTest.InitializeRevitConnection()
at TUnit.Generated.Hooks.Nice3point_TUnit_Revit_RevitApiTest_RevitSessionSetup_Before_TestSession.Nice3point_TUnit_Revit_RevitApiTest_RevitSessionSetup_Before_TestSessionInitializer.<>c.<global_Nice3point_TUnit_Revit_RevitApiTest_RevitSessionSetup_0Params_Body>b__0_0()
This reproduces identically whether invoked from a bash/MSYS shell or from native Windows PowerShell, ruling out a shell-specific process-creation quirk.
Environment
- OS: Windows, build
10.0.26200
- Revit 2024,
RevitAPI.dll file version 24.3.40.26
Nice3point.Revit.Sdk 6.2.3
Nice3point.TUnit.Revit 2024.1.1 (resolved via $(RevitVersion).*)
Nice3point.Revit.Injector / PolyHook2.NET 1.1.3 (transitive, PrivateAssets="all")
dotnet SDK 10.0.400
- TUnit engine
v1.44.0.0 (per the test-run banner)
- Ran via
dotnet run -c Debug.R24 (dotnet test is refused outright on this SDK: "Testing with VSTest target is no longer supported by Microsoft.Testing.Platform on .NET 10 SDK and later")
Things I ruled out before filing
- No leftover
Revit.exe or test-host processes from earlier runs (tasklist clean).
- No Attack Surface Reduction rules or Controlled Folder Access configured (
Get-MpPreference).
- HVCI / Memory Integrity / Credential Guard all off (
Win32_DeviceGuard: SecurityServicesRunning: {0}), CET/Shadow Stacks not forced at the system level.
- No named EDR agent (CrowdStrike/SentinelOne/etc.) running as a service.
- Not shell-specific (same failure from
bash and native PowerShell).
- Not fixed by a full OS reboot.
Possible relevant environmental factor (unconfirmed)
This machine also has an unrelated, unrelated-vendor Revit add-in of ours deployed per-user under %AppData%\Autodesk\Revit\Addins\2024\2025\2026\ (from normal Nice3point.Revit.Sdk DeployAddin=true debug builds of a separate project). We haven't yet tested with that add-in's manifest temporarily removed, so we can't confirm or rule out an interaction between that add-in's normal (UI-expecting) OnStartup and the injector's restricted "database-level Application" bootstrap — flagging it in case it's a known interaction class.
Happy to gather more diagnostics (procmon trace, memory dump, etc.) if useful.
Steps to reproduce
Sdk="Nice3point.Revit.Sdk/6.2.3",<OutputType>Exe</OutputType>,<Configurations>Debug.R24</Configurations>), referencing:ApplicationTestssample from the README / your own test project:dotnet run -c Debug.R24(also reproduced with-c Debug.R25;-c Debug.R26fails separately/earlier with aRevitAPI, Version=26.4.0.0FileNotFoundException, since the installed Revit 2026 update —RevitAPI.dllfile version26.5.0.55— is newer than the latest publishedNice3point.Revit.Api.RevitAPIpackage,2026.4.10).✔️ Expected Behavior
The test session initializes,
InjectApplication()succeeds, and the test runs against the liveApplication.❌ Actual Behavior
The first run on this machine succeeded (R24 and R25 both passed cleanly). Every run since — including after a full machine reboot — fails deterministically in
BeforeTestSessionwith:This reproduces identically whether invoked from a
bash/MSYS shell or from native Windows PowerShell, ruling out a shell-specific process-creation quirk.Environment
10.0.26200RevitAPI.dllfile version24.3.40.26Nice3point.Revit.Sdk6.2.3Nice3point.TUnit.Revit2024.1.1(resolved via$(RevitVersion).*)Nice3point.Revit.Injector/PolyHook2.NET1.1.3(transitive,PrivateAssets="all")dotnetSDK10.0.400v1.44.0.0(per the test-run banner)dotnet run -c Debug.R24(dotnet testis refused outright on this SDK: "Testing with VSTest target is no longer supported by Microsoft.Testing.Platform on .NET 10 SDK and later")Things I ruled out before filing
Revit.exeor test-host processes from earlier runs (tasklistclean).Get-MpPreference).Win32_DeviceGuard:SecurityServicesRunning: {0}), CET/Shadow Stacks not forced at the system level.bashand native PowerShell).Possible relevant environmental factor (unconfirmed)
This machine also has an unrelated, unrelated-vendor Revit add-in of ours deployed per-user under
%AppData%\Autodesk\Revit\Addins\2024\2025\2026\(from normalNice3point.Revit.SdkDeployAddin=truedebug builds of a separate project). We haven't yet tested with that add-in's manifest temporarily removed, so we can't confirm or rule out an interaction between that add-in's normal (UI-expecting)OnStartupand the injector's restricted "database-levelApplication" bootstrap — flagging it in case it's a known interaction class.Happy to gather more diagnostics (procmon trace, memory dump, etc.) if useful.