oscarkuo
oscarkuo

Reputation: 10453

Trigger IIS AppPool recycle within a WCF service

I am working on a web service that interacts with an unstable third-party C++ DLL.

It frequently throws AccessViolationException (i.e., a crash within the DLL) and the only way to recover is to recycle the app pool.

Is there a way to programmatically recycle the app pool?

Note: I tried to change timestamps of my .NET DLLs and web.config but that doesn't seem to do enough to get the w3wp.exe process to unload the native C++ DLL. I can't touch the C++ DLL because it comes back with an error: "the DLL is in use".

Upvotes: 4

Views: 1021

Answers (1)

Cheeso
Cheeso

Reputation: 192637

If you have access to the box, you can use appcmd.exe :

C:\dev>\windows\system32\inetsrv\appcmd.exe apppool  /?
Administration of application pools

APPCMD (command) APPPOOL <identifier> <-parameter1:value1 ...>

Supported commands:

  list      List application pools
  set       Configure application pool
  add       Add new application pool
  delete    Delete application pool
  start     Start application pool
  stop      Stop application pool
  recycle   Recycle application pool

(To get help for each command use /?, e.g. 'appcmd.exe add site /?'.)

To use that from within code you'd need to use System.Diagnostics.Process to run the appropriate recycle command.

Upvotes: 0

Related Questions