A Common IronPython References Error

I’ve been encountering a common error when answering reader emails for Professional IronPython. The problem is compounded by the fact that the error messages readers receive vary and there seems to be little consistency in the way Visual Studio reacts to the error. When making references to a .NET assembly in IronPython, you must include the .DLL extension. Otherwise, the IDE is going to give you a very odd error message nearly every time. For example, if you want to reference the System.Drawing assembly, you’d use the AddReference() method like this:

import clr

When working with the book, Chapter 7 tells how to interact with the .NET Framework. In fact, you can find the procedure for importing a CLR assembly on page 125. In addition to importing clr, you also need to provide a path for finding the assemblies as shown in the example code.  Chapter 8, page 143, shows a simple example of a Windows Forms application. Most readers find the code in Listing 8-1 really helpful.

Making matters worse, some readers have told me that they have been able to make applications work without including the .DLL part of the file name, but I’m finding including the whole file name works better. These odd errors are a concern for me, so please let me know if you continue to experience problems with IronPython, Python Tools for Visual Studio (PTVS), or the use of NumPy and SciPy at John@JohnMuellerBooks.com. I’ll try to reproduce the error on my system so that I can troubleshoot it with greater ease. If I can’t reproduce the error, I’ll likely need some additional input and testing from you.


Author: John

John Mueller is a freelance author and technical editor. He has writing in his blood, having produced 99 books and over 600 articles to date. The topics range from networking to artificial intelligence and from database management to heads-down programming. Some of his current books include a Web security book, discussions of how to manage big data using data science, a Windows command -line reference, and a book that shows how to build your own custom PC. His technical editing skills have helped over more than 67 authors refine the content of their manuscripts. John has provided technical editing services to both Data Based Advisor and Coast Compute magazines. He has also contributed articles to magazines such as Software Quality Connection, DevSource, InformIT, SQL Server Professional, Visual C++ Developer, Hard Core Visual Basic, asp.netPRO, Software Test and Performance, and Visual Basic Developer. Be sure to read John’s blog at http://blog.johnmuellerbooks.com/. When John isn’t working at the computer, you can find him outside in the garden, cutting wood, or generally enjoying nature. John also likes making wine and knitting. When not occupied with anything else, he makes glycerin soap and candles, which comes in handy for gift baskets. You can reach John on the Internet at John@JohnMuellerBooks.com. John is also setting up a website at http://www.johnmuellerbooks.com/. Feel free to take a look and make suggestions on how he can improve it.