Recently was adding NLog into a .Net exe. Took the opportunity to recompile to .Net 4.6 from .Net 2.0. The exe calls a vendor library which uses .net 2.0. Certain method of the vendor library throws a Request Failed that indicates a securityPermission exception when the vendor library tries to call OpenMutex. Disassembling the vendor lib shows the offending code:
[SecurityPermission(SecurityAction.PermitOnly)]
static private void InitMutex(string path)
{
string name = string.Format("AMutexName");
if (dataMutex != null)
{
//this.FinalizeMutex();
}
bool flag;
dataMutex = new OpenMutex(false, Common.GlobalMutexName(name), out flag);
The issue appears to be with the attribute action of PermitOnly. I added the code directly into the 4.6 exe for easier testing and found if I change securityaction to almost any other value the OpenMutex calls succeeds. My question is if there is a way to grant permissions to my exe so the vendor code will succeed? The original EXE compiled under 2.0 works.