How can I use MiniProfiler with a WinForm Projects?


#1

Is there any way to use MiniPrifiler with non-web solutions?
For example WinForms?


#2

As long as you don’t have any problem including references to System.Web, you should be able to run MiniProfiler in a WinForms app. However, you will need to do a number of things on your own:

  1. Init the MiniProfiler global settings when you start the app (in place of code that normally goes in Global.asax)
  2. Start and Stop MiniProfiler sessions. This is normally done in a webapp when a request begins and ends. However, in a WinForms app that doesnt follow the pattern of web requests being processed on a server, you will have to come up with your own paradigm for when a MiniProfiler session should start and stop.
  3. Set up an IStorage option that does not use the default of the ASP.net cache. There are out of box IStorage solutions included for Sql Server, and you can make your own as well.
  4. Most importantly - you will not have access to RenderIncludes or any of the UI that is provided in the web releases for retrieving and displaying results. Of course, you could save the results to a DB, and then access those results from a different web front-end using the provided options. Or you could find some other way to evaluate the results on your own. But it is something to take into consideration.
  5. (I am probably missing something else)

So: doable - yes. But will definitely require extra work.