I am facing a pretty weird issue, and I can't understand even after hours of research, so that's why I am sharing this problem.
I created a little Windows Form which is working perfectly on my computer, both with a Debug version and a release version. Everything was pretty nice, until I tried to launch it on the computer which is supposed to really use it. I got the famous CLR20r3 error, so I search on Internet and saw various possible causes :
- References used by the software might not be on the computer which is running the software, so I added all the references as local copies.
- It could be a .NET issue, so I uninstall and re-installed it.
- It might be some specific CPU weird standard, so I tried to deploy it for x86 only.
But none of those solutions worked. After hours and hours of trials, compilations and reseaches, I found the cause : I have this specific part in my code, which is supposed to remove any extra-spaces from logs strings :
for(int i = 0; i < lastlogs.Length; i++)
{
RegexOptions options = RegexOptions.None;
Regex regex = new Regex("[ ]{2,}", options);
lastlogs[i] = regex.Replace(lastlogs[i], " ");
}
If I comment out this part, the code is running perfectly. I added a reference to System.Text.RegularExpressions
, but I can't see it in the assemblies list, so I suppose it is some kind of build-in Windows assembly. But if that's the case, it's strange that the software crashes because it can't find it...
I would like to understand why this crash is happening, and if anyone have a possible way to solve this problem.