I’m using .NET profiling api to instrument my .NETCore application running on Linux. I need to find all the assemblies loaded in my application.
I’ve enabled the flag COR_PRF_MONITOR_ASSEMBLY_LOADS to receive notifications when assemblies are loaded into the Common Language Runtime.
Below is my code to get the Assembly name. It works as expected in windows machine. But when I run the same in Linux environment it is not giving the correct assembly name. On linux I’m getting the assembly name something like this “Sse.igotc.rcn.Lgigule����”
From my search I found that this can be character encoding issue. I even set encoding std::setlocale(LC_ALL, "");
in my code. But still no luck.
bool CAssemblyManager::Initialize(AssemblyID assemblyId)
{
ULONG nameLength = 0;
_corProfilerInfo2->GetAssemblyInfo(assemblyId, 0, &nameLength, 0, 0, 0);
wchar_t* nameBuffer = new wchar_t[nameLength];
_corProfilerInfo2->GetAssemblyInfo(assemblyId, nameLength, 0, nameBuffer, 0, 0);
delete[] nameBuffer;
return true;
}
I also tried to convert the wchar_t* string to a std::string encoded in UTF-8 using std::wstring_convert. But it is also not working
std::wstring_convert<std::codecvt_utf8<wchar_t>> converter;
converter.to_bytes(nameBuffer);
std::cout << converter.to_bytes(nameBuffer) << std::endl;
What could be the issue. If it is encoding issue Am I missing something? Or is it an issue with .NET Profiling API method (“GetAssemblyInfo()”). As I said earlier it happens only in Linux.
RANJITH M is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.