-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Labels
Description
-
I have written a small wrapper with some XLIFF handling using DeepL.NET.
- When creating unit test with MS Test, the test failed with a System.IO.FileLoad.Exception for System.Text.Json.
- When I use the same code in an executable, it worked fine.
-
Next, I have created some code which uses DeepL.NET directly.
- Again, it works in the executable:
namespace Test_DeepLLibExe
{
internal class Program
{
static async Task Main(string[] args)
{
const string ApiKey = "xxxxx";
try
{
using (Translator client = new Translator(ApiKey))
{
var languages = await client.GetTargetLanguagesAsync();
}
}
catch (Exception ex)
{
Console.WriteLine($"ERROR: {ex.Message}");
}
. . .+ => list of 31 languages
- And fails, when called from a unit test with MS Test:
[TestMethod]
public async Task Test_DeepLDirect()
{
_logger.Info($"--- Starting {GetCurrentMethod()} ...");
const string ApiKey = "xxxxx";
try
{
using (Translator client = new Translator(ApiKey))
{
var languages = await client.GetTargetLanguagesAsync();
}
}
catch (Exception ex)
{
_logger.Error($"Global error in {GetCurrentMethod()}: {ex.Message}");
}
}+ => System.IO.FileLoad.Exception for System.Text.Json
+ Message: "Could not load file or assembly 'System.Text.Json, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)":"System.Text.Json, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51"
+ Source: "DeepL.net"
+ StackTrace: " at DeepL.Internal.DeepLClient.<CheckStatusCodeAsync>d__10.MoveNext()\r\n at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)\r\n at DeepL.Internal.DeepLClient.CheckStatusCodeAsync(HttpResponseMessage responseMessage, Boolean usingGlossary, Boolean downloadingDocument)\r\n at DeepL.Translator.<GetLanguagesAsync>d__30`1.MoveNext()\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at DeepL.Translator.<GetTargetLanguagesAsync>d__19.MoveNext()\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n at Test_Kostal.ActivePresenter.DeepLLib.Test_DeepLRunner.<Test_DeepLDirect>d__28.MoveNext() in C:\\Users\\wagner06\\source\\APH\\activepresenterlib\\Test_DeepLLib\\Test_DeepLRunner.cs:line 277"
(screenshots have been inserted and uploaded, but that seems to be blocked)
- In all cases, the binary folder contains System.Text.Json.dll in version 8.0.123.58001, so I do not understand the reference failure.
Expected behaviour: The code should be testable with MSTest without problems.
- I have been using
- VisualStudio 2022 (Version 17.7.0)
- .NET Framework 4.8.1,
- MSTest.TestAdapter/TestFramework (V3.2.0),
- DeepL.net (Version 1.8.0) loaded with nuget and referenced with package references.
Additional info: A colleague from IT meant, that an improper nuget package definition might cause this problem.
JanEbbing