Loading Solidworks API using Winforms under IIS

I am developing a system where user interacts with WCF Service hosted in IIS server. The WCF application then have to fire-up winform application along with some parameters. This winform application do some processing and then load a Solidworks application(software) installed on the server. This Solidworks will create some output files and put it in the share-able folder where user has a access to.

It is working fine in development environment (Visual Studio) but when I deployed it in IIS, it throws following error:

COMException was unhandled An unhandled exception of type System.Runtime.InteropServices.COMException' occurred in mscorlib.dll

I tried loading the WinForm using two methods:

  • Winform is loaded creating a instance of WinForm from WCF host
  • Executable of WinForm is loaded (.EXE) using System.Diagnostics.Process.Start()

I tried following:

  1. Running IIS under domain admin identity
  2. Disabling UAC

Both operation failed. I tried giving AppPool "Local System“ and “Doman admin” identity but doing that It started throwing me visual studio runtime exception “ An unhandled exception of type System.Runtime.InteropServices.COMException' ". I tried converting the program into x86 too but it did not work. But when I run the application independently, it is working fine.

When I tried debugging, it is not working in this line:

SldWorks swApp = Activator.CreateInstance(Type.GetTypeFromProgID("SldWorks.Application")) as SldWorks; 
SolidworksApi macros