Well I translated your code to C# and I got this
string SDD_HOME_env_var = Environment.GetEnvironmentVariable("SDD_HOME");
if (String.IsNullOrEmpty(SDD_HOME_env_var))
{
//MGCPCBReleaseEnvServer vxEnv = new MGCPCBReleaseEnvServer();
var vxEnv = new MGCPCBReleaseEnvironmentLib.MGCPCBReleaseEnvServer();
vxEnv.SetEnvironment();
SDD_HOME_env_var = vxEnv.sddHome;
int idx = SDD_HOME_env_var.IndexOf("SDD_HOME");
SDD_HOME_env_var = SDD_HOME_env_var.Substring(0, idx).Replace(@"\", @"\\") + "SDD_HOME";
vxEnv.SetEnvironment(SDD_HOME_env_var);
}
Trying to set the vxEnv variable I always get the error "A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll"
I have two lines there for setting the vxEnv variable, first one is currently commented out but should work as well. I also get the same COMException error here.
I have the MGCPCBReleaseEnvironmentLib referenced for this project as well. Am I missing a reference maybe?