I've not been able to figure out how to import Package from System.IO.Packaging. Below is some code to illustrate my problem. (I've run this code in IronPython 2.0A6 and 1.1. I have .NET 3.0 installed.) Basically,
from System.IO import Packaging gives me the error ImportError: Cannot import name Packaging whereas something like from System.IO import FileStream, FileMode, FileAccess works fine. Part of the issue is that System.IO.Packaging is part of .NET 3.0 but not .NET 2.0 -- but I can certainly access other libraries (assemblies? I'm new to .NET) -- such as System.Speech -- as show below. Is the problem that there is no System.Speech at all in .NET 2.0 but there is already a System.IO in .NET 2.0 -- so IronPython can't pick up the .NET 3.0 parts of System.IO? I know that System.IO.Packaging is on my system -- I have some C# code that uses it. Thanks in advance for any help! -Raymond Yee ----------------------------------- Here's the code: # documenting my problem with getting System.IO.Packaging to work in ipy import clr # I can't figure out how to load System.IO.Packaging -- which is part of .NET 3.0 # http://msdn2.microsoft.com/en-us/library/system.io.packaging.package.aspx is part of .NET 3.0 try: from System.IO import Packaging print "success: from System.IO import Packaging" except: print "error: from System.IO import Packaging" # http://www.ironpython.info/index.php/SHA1Managed_from_System.Security.Cryptography # shows that we can access System.IO.{FileStream, FileMode, FileAccess} from System.IO import FileStream, FileMode, FileAccess print "success: from System.IO import FileStream, FileMode, FileAccess" # I can get at other assemblies that are .NET 3.0 # e.g., http://msdn2.microsoft.com/en-us/library/system.speech.synthesis.aspx try: clr.AddReference('System.Speech') from System.Speech.Synthesis import SpeechSynthesizer print "success: adding System.Speech" except: print "error: adding System.Speech" # print out why System.IO doesn't contain Packaging import System print "dir(System.IO): \n" , dir(System.IO), "\n" # print out the references that are available print "clr.References:" for r in clr.References: print r # Is the problem that there is no System.Speech at all in .NET 2.0 but there is already a System.IO in .NET 2.0 -- so # IronPython can't pick up the .NET 3.0 parts of System.IO? ----------------- Here's the output I get: error: from System.IO import Packaging success: from System.IO import FileStream, FileMode, FileAccess success: adding System.Speech dir(System.IO): ['BinaryReader', 'BinaryWriter', 'BufferedStream', 'Compression', 'Directory', 'DirectoryInfo', 'DirectoryNotFoundException', 'DriveInfo', 'DriveNotFoundException', 'DriveType', 'EndOfStreamException', 'ErrorEventArgs', 'ErrorEventHandler', 'File', 'FileAccess', 'FileAttributes', 'FileInfo', 'FileLoadException', 'FileMode', 'FileNotFoundException', 'FileOptions', 'FileShare', 'FileStream', 'FileSystemEventArgs', 'FileSystemEventHandler', 'FileSystemInfo', 'FileSystemWatcher', 'IODescriptionAttribute', 'IOException', 'InternalBufferOverflowException', 'InvalidDataException', 'IsolatedStorage', 'MemoryStream', 'NotifyFilters', 'Path', 'PathTooLongException', 'Ports', 'RenamedEventArgs', 'RenamedEventHandler', 'SearchOption', 'SeekOrigin', 'Stream', 'StreamReader', 'StreamWriter', 'StringReader', 'StringWriter', 'TextReader', 'TextWriter', 'UnmanagedMemoryStream', 'WaitForChangedResult', 'WatcherChangeTypes'] clr.References: mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 System.Speech, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 _______________________________________________ Users mailing list [email protected] http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
