Wir haben mehrere Projekte in einer Visual Studio 2022 (17.13.2, möglicherweise nicht relevant), 1 C# Konsolenanwendung, die auf .NET 8, 1 CLR -Projekt abzielt, auch auf .NET 8 und zuletzt eine C ++ statische Lib. Alle Projekte sind neu mit ihren jeweiligen VS -Vorlagen erstellt. Code:
Code: Select all
#include "pch.h"
#include
namespace ExceptionTestAppCPP
{
class CPPClass
{
public:
void Test()
{
throw new std::exception("Test exception");
}
};
}
CLR-Projekte Code:
Code: Select all
#pragma once
#include
#include
namespace ExceptionTestAppCLR
{
public ref class CLRClass
{
public:
void Test()
{
try
{
ExceptionTestAppCPP::CPPClass cppClass;
cppClass.Test();
}
catch (std::exception* ex)
{
throw;
}
catch (...)
{
throw;
}
}
};
}
C# Projekte Code:
namespace ExceptionTestAppCSharp
{
internal class Program
{
static void Main(string[] args)
{
try
{
var clr = new ExceptionTestAppCLR.CLRClass();
clr.Test();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
}
}
< /code>
Ausführen des Codes führt zu einer statischen Ausnahme in den statischen Libs Cpplass -Test () und fangen von den CLR -Codes CLRCLASS -Test () in seiner Fang (std :: Ausnahme* ex) Block.
Dieses Ergebnis wird erwartet. Seien Sie als System erwischt :: Ausnahme durch den Block (...). entfernt werden und dennoch das
Problem verursachen. Handling. Code, den wir verwenden, den wir nicht besitzen oder nicht mehr gepflegt werden.>
Wir haben mehrere Projekte in einer Visual Studio 2022 (17.13.2, möglicherweise nicht relevant), 1 C# Konsolenanwendung, die auf .NET 8, 1 CLR -Projekt abzielt, auch auf .NET 8 und zuletzt eine C ++ statische Lib. Alle Projekte sind neu mit ihren jeweiligen VS -Vorlagen erstellt. Code:
[code]#include "pch.h"
#include
namespace ExceptionTestAppCPP
{
class CPPClass
{
public:
void Test()
{
throw new std::exception("Test exception");
}
};
}
[/code]
[b] CLR-Projekte Code: [/b]
[code]#pragma once
#include
#include
namespace ExceptionTestAppCLR
{
public ref class CLRClass
{
public:
void Test()
{
try
{
ExceptionTestAppCPP::CPPClass cppClass;
cppClass.Test();
}
catch (std::exception* ex)
{
throw;
}
catch (...)
{
throw;
}
}
};
}
[/code]
[b] C# Projekte Code: [/b]
namespace ExceptionTestAppCSharp
{
internal class Program
{
static void Main(string[] args)
{
try
{
var clr = new ExceptionTestAppCLR.CLRClass();
clr.Test();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
}
}
< /code>
Ausführen des Codes führt zu einer statischen Ausnahme in den statischen Libs Cpplass -Test () und fangen von den CLR -Codes CLRCLASS -Test () in seiner Fang (std :: Ausnahme* ex) Block.
Dieses Ergebnis wird erwartet. Seien Sie als System erwischt :: Ausnahme durch den Block (...). entfernt werden und dennoch das [url=viewtopic.php?t=15738]Problem[/url] verursachen. Handling. Code, den wir verwenden, den wir nicht besitzen oder nicht mehr gepflegt werden.>