c# – check if form exist and open it if not

FormType myForm = Application.OpenForms.OfType<FormType>().FirstOrDefault();

if(myForm != null)

{

myForm.Show();

}

else

{

myForm = new FromType();

myForm.Show();

}

Advertisements

Run c# program In Jenkins, cannot save Excel files

Usually get this error:

System.Runtime.InteropServices.COMException (0x800A03EC): Microsoft Excel cannot open or save any more documents

After SaveAs method

 

to solve this problem do this works:

  1. Create directory “C:\Windows\SysWOW64\config\systemprofile\Desktop ” (for 64 bit Windows) or “C:\Windows\System32\config\systemprofile\Desktop ” (for 32 bit Windows)
  2. Set Full control permissions for directory Desktop (for example in Win7 & IIS 7 & DefaultAppPool set permissions for user
    “IIS AppPool\DefaultAppPool”

 

See here foe more details: