MonoMod.Common icon indicating copy to clipboard operation
MonoMod.Common copied to clipboard

.NET 8 support issue

Open menaTitan opened this issue 1 year ago • 3 comments

Application Details

  • Target Framework: .NET 8
  • Previous Framework: .NET 6

The application is an ASP.NET Core web API that uses the MonoMod.Common library and the Softwarehelden.Transactions.Oletx library to patch the OleTx implementation in System.Transactions and the System.Data.SqlClient library for supporting distributed transactions with MSSQL and Oracle servers.

Steps to Reproduce

  1. Update the project's target framework from .NET 6 to .NET 8.
  2. Build and run the application.
  3. The System.NullReferenceException is thrown during the application startup.

Expected Behavior

The application should start successfully and run without any exceptions when targeting .NET 8.

Additional Information

  • I have already tried updating to the latest versions of the MonoMod.Common and Softwarehelden.Transactions.Oletx libraries, but the issue persists.
  • I have also reviewed the documentation and release notes for these libraries, but there are no known issues or compatibility concerns mentioned for .NET 8.

Any assistance or guidance in resolving this issue would be greatly appreciated. Please let me know if you need any additional information or if you have any suggestions on how to proceed.

menaTitan avatar Mar 13 '24 19:03 menaTitan

As mentioned on the main MonoMod repo in other issues, MonoMod was recently rewritten and the what was MonoMod.Common is now (roughly, the actual API has essentially completely changed) MonoMod.Core, with included support for net7 and net8. See https://github.com/MonoMod/MonoMod/issues/94

Windows10CE avatar Mar 13 '24 19:03 Windows10CE

As a side note, I would recommend changing to use MonoMod.RuntimeDetour instead of trying to use Core directly.

Windows10CE avatar Mar 13 '24 19:03 Windows10CE

How can I accomplish the same thing, like this: OletxPatcher.Patch(); MsSqlPatcher.Patch(typeof(SqlConnection).Assembly);, using the new MonoMod.Core library?

public static async Task<ExitCode> RunApplicationAsync(string[] args) { try { OletxPatcher.Patch(); MsSqlPatcher.Patch(typeof(SqlConnection).Assembly);

    Console.WriteLine("Configuring...");
    var app = CreateWebApplicationBuilder(args).Build();
    app.ConfigureApplicationPipeline();
    Console.WriteLine("Running");
    await app.RunAsync();
    return ExitCode.Success;
}
catch (TaskCanceledException)
{
    return ExitCode.Success;
}
catch (Exception ex)
{
    await Console.Error.WriteLineAsync($"Fatal error starting application. {ex}");
    return ExitCode.GeneralFailure;
}
finally
{
    await Log.CloseAndFlushAsync();
}

}

menaTitan avatar Mar 15 '24 14:03 menaTitan