Fixed the wrong version of .NET Runtime being loaded
This commit is contained in:
parent
f279f1f54c
commit
76847a4d9c
|
@ -76,15 +76,14 @@ namespace SHADE
|
|||
if (coreClr == nullptr)
|
||||
{
|
||||
// Construct the CoreCLR path
|
||||
std::string coreClrPath("C:\\Program Files\\dotnet\\shared\\Microsoft.NETCore.App\\5.0.17"); // Works
|
||||
coreClrPath += "\\coreclr.dll";
|
||||
const std::string CORE_CLR_PATH = DOT_NET_PATH->string() + "\\coreclr.dll";
|
||||
|
||||
// Load the CoreCLR DLL
|
||||
coreClr = LoadLibraryExA(coreClrPath.c_str(), nullptr, 0);
|
||||
coreClr = LoadLibraryExA(CORE_CLR_PATH.c_str(), nullptr, 0);
|
||||
if (!coreClr)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << "[DotNetRuntime] Error #" << GetLastError() << " Failed to load CoreCLR from \"" << coreClrPath << "\"\n";
|
||||
oss << "[DotNetRuntime] Error #" << GetLastError() << " Failed to load CoreCLR from \"" << CORE_CLR_PATH << "\"\n";
|
||||
throw std::runtime_error(oss.str());
|
||||
}
|
||||
|
||||
|
@ -100,7 +99,7 @@ namespace SHADE
|
|||
// trusted system assemblies (similar to the .NET Framework GAC).
|
||||
// For this host (as with most), assemblies next to CoreCLR will
|
||||
// be included in the TPA list
|
||||
std::string tpaList = buildTpaList(DOT_NET_PATH->string());
|
||||
std::string tpaList = buildTpaList(DOT_NET_PATH->string()) + buildTpaList(runtimePath);
|
||||
|
||||
// Define CoreCLR properties
|
||||
std::array propertyKeys =
|
||||
|
@ -159,7 +158,7 @@ namespace SHADE
|
|||
std::string SHDotNetRuntime::buildTpaList(const std::string& directory)
|
||||
{
|
||||
// Constants
|
||||
static const std::string SEARCH_PATH = directory + "\\*.dll";
|
||||
const std::string SEARCH_PATH = directory + "\\*.dll";
|
||||
static constexpr char PATH_DELIMITER = ';';
|
||||
|
||||
// Create a osstream object to compile the string
|
||||
|
@ -249,12 +248,20 @@ namespace SHADE
|
|||
const auto thisMinor = stoi(VERSION_TOKENS[1]);
|
||||
const auto thisRevision = stoi(VERSION_TOKENS[2]);
|
||||
|
||||
if (major > thisRevision)
|
||||
// Only pass if the version is greater
|
||||
if (major > thisMajor)
|
||||
continue;
|
||||
else if (major == thisMajor)
|
||||
{
|
||||
if (minor > thisMinor)
|
||||
continue;
|
||||
else if (minor == thisMinor)
|
||||
{
|
||||
if (revision > thisRevision)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
major = thisMajor;
|
||||
minor = thisMinor;
|
||||
|
|
Loading…
Reference in New Issue