tags:

views:

70

answers:

2

In java you can set a "headless" flag to true to reconcile the differences between a headless server environment and your desktop development environment.

System.setProperty("java.awt.headless", "true");

So whenever you try to do an operation not supported in a headless environment the VM throws an Exception

What are the settings or flags I can modify to simulate my application running in an IIS app pool instead of the local .NET VM?

Edit: to clarify my intentions, I am going to use code that calls System.Windows.Forms.dll, WindowsBase.dll etc and the openGL wrapper OpenTK that might instantiate a window.

+1  A: 

If you want your code not to compile if you instantiate a window, simply don't reference System.Windows.Forms.dll (WinForms) nor WindowsBase.dll (WPF).

Martinho Fernandes
+1. Simple, yet probably very effective :-)
Joey
+3  A: 

simulate my application running in an IIS app pool instead of the local .NET VM?

Well, the local VM won't be miles out (assuming you're hosting in some kind of web-server), but to be honest - why simulate? Host it in IIS; that is fine. To check for subtle server OS issues, I run a server OS in a VM and deploy / remote-debug etc to that.


To check at runtime, you might check Environment.UserInteractive; most service-based code will report false - where-as winforms etc will return true.

IMO, this is rarely an issue, though.

Marc Gravell