Tag: ironpython


How to check if an assembly was compiled in debug or release mode

January 8th, 2010 — 6:18pm

I came across this nifty bit of code the other day when looking for a way to do this and, just for fun, thought I’d convert it to IronPython. So I did. And here it is:

import System

def is_assembly_debug_build(filename):
	"""Returns true if filename appears to have been built in debug mode"""
	result = False
	dll = System.Reflection.Assembly.LoadFile(filename)
	customAttribs = dll.GetCustomAttributes(False)
	for att in customAttribs:
		if att.GetType() == System.Type.GetType("System.Diagnostics.DebuggableAttribute"):
			result = att.IsJITTrackingEnabled
	return result

I saved this in a file called diagnostics.py. So using it (you’ll need to be in the same directory as diagnostics.py or have added diagnostics.py to your path – more info can be found here: http://docs.python.org/tutorial/modules.html#the-module-search-path) is simply a matter of doing something like this:

from diagnostics import is_assembly_debug_build
is_assembly_debug_build([absolute_path_to_your_dll])

If you’re interested you can grab a copy of diagnostics.py from http://gist.github.com/206177

Have fun :-)

Comment » | devtools

Get Started With IronPython on Silverlight 2.0

March 9th, 2008 — 2:36pm

If you want to have a go with IronPython on Silverlight 2.0, you could do worse than to follow the advice in this article. Although the example is rather simplistic it should get you up and running in no time.

As the Chiron tool is in the Microsoft SDK’s folder, I am presuming that you will need to install the Silverlight 2.0 SDK first (as well as the Silverlight 2.0 runtime of course). These can be downloaded from here:

Have fun!

Comment » | silverlight

Setting up the Silverlight DLRConsole on Apache

February 29th, 2008 — 11:52pm

If, like me, you fancied playing around with IronPython and Silverlight on Apache, here’s how I got mine set-up:

  1. Download and unpack DLRConsole.zip from http://silverlight.net/Samples/1.1/DLR-Console/DLRConsole.zip
  2. Added the following to my Apache httpd.conf file:
     <VirtualHost 127.0.0.1>
             ServerName DLRConsole
             DocumentRoot "C:/dev/DLRConsole"
             AddType text/python .py
             AddType text/jscript .jsx
    
             DirectoryIndex index.htm index.html
    </VirtualHost>
    
    <Directory "C:/dev/DLRConsole">
             Options Indexes MultiViews
             AllowOverride None
             Order allow,deny
             Allow from all
    
             DirectoryIndex index.htm index.html
    </Directory>
    
  3. I also set up the following in my hosts file (typically located on Windows at C:WINDOWSSYSTEM32DRIVERSETCHOSTS):
    127.0.0.1 dlrconsole
  4. Re-start Apache and point your browser to http://dlrconsole

You may need to comment out any other Python handlers in you httpd.conf file and add them on a per <Directory> basis, but obviously if you’ve got loads of Python-based sites on your Apache installation then your mileage may vary. Fortunately this wasn’t an issue for me so the following was sufficient:

AddHandler cgi-script .pl
#AddHandler cgi-script .py

For more on the DLRConsole see this article from MSDN Magazine.

Comment » | Uncategorized

Back to top