Accessing Public Functions in Module
We have an application that was developed in Visual Basic, and would like to use Python for .NET to extend it. I've played around with it a bit, and everything works fine if it is within a class in the .Net assembly. However, there are a number of components that exist as public functions within a module. I cannot seem to access them from Python for .NET. My latest session is shown below, where I try to import and use the function, "NonQuery" within the module, "SQL_Module" to no avail. Thanks for any help, and thanks for this wonderful piece of software. I can't wait to start programming some things with this instead of Visual Basic. Microsoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp. Z:\>\\buffalo02\share\IT\python\python\python.exe Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information.
import Nepco4 Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named Nepco4 from NepcoV2 import Order from NepcoV2 import NonQuery Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: cannot import name NonQuery from NepcoV2 import SQL_Module.NonQuery File "<stdin>", line 1 from NepcoV2 import SQL_Module.NonQuery ^ SyntaxError: invalid syntax from NepcoV2.SQL_Module import NonQuery Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named SQL_Module import Nepco4.NepcoV2 Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named Nepco4.NepcoV2 from Nepco4 import NepcoV2 Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named Nepco4 from NepcoV2 import SQL_Module Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: cannot import name SQL_Module from NepcoV2 import SQL_Module5 Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: cannot import name SQL_Module5 from NepcoV2 import SQL_Modulf Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: cannot import name SQL_Modulf from NepcoV2 import Shipping_Detail_Report from NepcoV2 import * NonQuery() Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'NonQuery' is not defined NepcoV2.NonQuery() Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'NepcoV2' is not defined
Can you access these same functions in C#? Maybe what you have to do is write a wrapper library for your VB.NET library in C#, and have Python access the library through the the wrapper. - Feihong Kyle Stevens <kyle.stevens@thenortheastgroup.com> wrote: We have an application that was developed in Visual Basic, and would like to use Python for .NET to extend it. I've played around with it a bit, and everything works fine if it is within a class in the .Net assembly. However, there are a number of components that exist as public functions within a module. I cannot seem to access them from Python for .NET. My latest session is shown below, where I try to import and use the function, "NonQuery" within the module, "SQL_Module" to no avail. Thanks for any help, and thanks for this wonderful piece of software. I can't wait to start programming some things with this instead of Visual Basic. Microsoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp. Z:\>\\buffalo02\share\IT\python\python\python.exe Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information.
import Nepco4 Traceback (most recent call last): File "", line 1, in ImportError: No module named Nepco4 from NepcoV2 import Order from NepcoV2 import NonQuery Traceback (most recent call last): File "", line 1, in ImportError: cannot import name NonQuery from NepcoV2 import SQL_Module.NonQuery File "", line 1 from NepcoV2 import SQL_Module.NonQuery ^ SyntaxError: invalid syntax from NepcoV2.SQL_Module import NonQuery Traceback (most recent call last): File "", line 1, in ImportError: No module named SQL_Module import Nepco4.NepcoV2 Traceback (most recent call last): File "", line 1, in ImportError: No module named Nepco4.NepcoV2 from Nepco4 import NepcoV2 Traceback (most recent call last): File "", line 1, in ImportError: No module named Nepco4 from NepcoV2 import SQL_Module Traceback (most recent call last): File "", line 1, in ImportError: cannot import name SQL_Module from NepcoV2 import SQL_Module5 Traceback (most recent call last): File "", line 1, in ImportError: cannot import name SQL_Module5 from NepcoV2 import SQL_Modulf Traceback (most recent call last): File "", line 1, in ImportError: cannot import name SQL_Modulf from NepcoV2 import Shipping_Detail_Report from NepcoV2 import * NonQuery() Traceback (most recent call last): File "", line 1, in NameError: name 'NonQuery' is not defined NepcoV2.NonQuery() Traceback (most recent call last): File "", line 1, in NameError: name 'NepcoV2' is not defined
Python.NET mailing list - PythonDotNet@python.org http://mail.python.org/mailman/listinfo/pythondotnet --------------------------------- Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now.
Most likely the vb.net compiler does some shenanigans and places this (in the IL) in a place that might not be obvious (like a generated class). If you use reflector on the assembly you can probably discover what its real name is and try to import that from python. -Brian On 12/18/07 3:47 PM, "Feihong Hsu" <hsu.feihong@yahoo.com> wrote:
Can you access these same functions in C#? Maybe what you have to do is write a wrapper library for your VB.NET library in C#, and have Python access the library through the the wrapper.
- Feihong
Kyle Stevens <kyle.stevens@thenortheastgroup.com> wrote:
We have an application that was developed in Visual Basic, and would like to use Python for .NET to extend it. I've played around with it a bit, and everything works fine if it is within a class in the .Net assembly.
However, there are a number of components that exist as public functions within a module. I cannot seem to access them from Python for .NET.
My latest session is shown below, where I try to import and use the function, "NonQuery" within the module, "SQL_Module" to no avail.
Thanks for any help, and thanks for this wonderful piece of software. I can't wait to start programming some things with this instead of Visual Basic.
Microsoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp.
Z:\>\\buffalo02\share\IT\python\python\python.exe Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information.
>> import Nepco4 Traceback (most recent call last): File "", line 1, in ImportError: No module named Nepco4 >> from NepcoV2 import Order >> from NepcoV2 import NonQuery Traceback (most recent call last): File "", line 1, in ImportError: cannot import name NonQuery >> from NepcoV2 import SQL_Module.NonQuery File "", line 1 from NepcoV2 import SQL_Module.NonQuery ^ SyntaxError: invalid syntax >> from NepcoV2.SQL_Module import NonQuery Traceback (most recent call last): File "", line 1, in ImportError: No module named SQL_Module >> import Nepco4.NepcoV2 Traceback (most recent call last): File "", line 1, in ImportError: No module named Nepco4.NepcoV2 >> from Nepco4 import NepcoV2 Traceback (most recent call last): File "", line 1, in ImportError: No module named Nepco4 >> from NepcoV2 import SQL_Module Traceback (most recent call last): File "", line 1, in ImportError: cannot import name SQL_Module >> from NepcoV2 import SQL_Module5 Traceback (most recent call last): File "", line 1, in ImportError: cannot import name SQL_Module5 >> from NepcoV2 import SQL_Modulf Traceback (most recent call last): File "", line 1, in ImportError: cannot import name SQL_Modulf >> from NepcoV2 import Shipping_Detail_Report >> from NepcoV2 import * >> NonQuery() Traceback (most recent call last): File "", line 1, in NameError: name 'NonQuery' is not defined >> NepcoV2.NonQuery() Traceback (most recent call last): File "", line 1, in NameError: name 'NepcoV2' is not defined >>
Python.NET mailing list - PythonDotNet@python.org http://mail.python.org/mailman/listinfo/pythondotnet
Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. <http://us.rd.yahoo.com/evt=51733/*http://mobile.yahoo.com/;_ylt=Ahu06i62sR8H... tDypao8Wcj9tAcJ >
_________________________________________________ Python.NET mailing list - PythonDotNet@python.org http://mail.python.org/mailman/listinfo/pythondotnet
-------------------------- Brian Lloyd brian.lloyd@revolutionhealth.com
Thanks. I downloaded a reflector from: http://www.aisto.com/roeder/dotnet/ By using that I could see that the module in question was declared friend (default, if not specified.. I guess), not public. I made it public and can now access the functions within it. So the compiler didn't mangle anything, it was just me not knowing what I was doing :). But your idea worked anyway. Thanks again. Brian Lloyd wrote:
Most likely the vb.net compiler does some shenanigans and places this (in the IL) in a place that might not be obvious (like a generated class).
If you use reflector on the assembly you can probably discover what its real name is and try to import that from python.
-Brian
On 12/18/07 3:47 PM, "Feihong Hsu" <hsu.feihong@yahoo.com> wrote:
Can you access these same functions in C#? Maybe what you have to do is write a wrapper library for your VB.NET library in C#, and have Python access the library through the the wrapper.
- Feihong
*/Kyle Stevens <kyle.stevens@thenortheastgroup.com>/* wrote:
We have an application that was developed in Visual Basic, and would like to use Python for .NET to extend it. I've played around with it a bit, and everything works fine if it is within a class in the .Net assembly.
However, there are a number of components that exist as public functions within a module. I cannot seem to access them from Python for .NET.
My latest session is shown below, where I try to import and use the function, "NonQuery" within the module, "SQL_Module" to no avail.
Thanks for any help, and thanks for this wonderful piece of software. I can't wait to start programming some things with this instead of Visual Basic.
Microsoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp.
Z:\>\\buffalo02\share\IT\python\python\python.exe Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import Nepco4 Traceback (most recent call last): File "", line 1, in ImportError: No module named Nepco4 >>> from NepcoV2 import Order >>> from NepcoV2 import NonQuery Traceback (most recent call last): File "", line 1, in ImportError: cannot import name NonQuery >>> from NepcoV2 import SQL_Module.NonQuery File "", line 1 from NepcoV2 import SQL_Module.NonQuery ^ SyntaxError: invalid syntax >>> from NepcoV2.SQL_Module import NonQuery Traceback (most recent call last): File "", line 1, in ImportError: No module named SQL_Module >>> import Nepco4.NepcoV2 Traceback (most recent call last): File "", line 1, in ImportError: No module named Nepco4.NepcoV2 >>> from Nepco4 import NepcoV2 Traceback (most recent call last): File "", line 1, in ImportError: No module named Nepco4 >>> from NepcoV2 import SQL_Module Traceback (most recent call last): File "", line 1, in ImportError: cannot import name SQL_Module >>> from NepcoV2 import SQL_Module5 Traceback (most recent call last): File "", line 1, in ImportError: cannot import name SQL_Module5 >>> from NepcoV2 import SQL_Modulf Traceback (most recent call last): File "", line 1, in ImportError: cannot import name SQL_Modulf >>> from NepcoV2 import Shipping_Detail_Report >>> from NepcoV2 import * >>> NonQuery() Traceback (most recent call last): File "", line 1, in NameError: name 'NonQuery' is not defined >>> NepcoV2.NonQuery() Traceback (most recent call last): File "", line 1, in NameError: name 'NepcoV2' is not defined >>> _________________________________________________ Python.NET mailing list - PythonDotNet@python.org http://mail.python.org/mailman/listinfo/pythondotnet
------------------------------------------------------------------------ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. <http://us.rd.yahoo.com/evt=51733/*http://mobile.yahoo.com/;_ylt=Ahu06i62sR8H... > <http://us.rd.yahoo.com/evt=51733/*http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ%20>
------------------------------------------------------------------------ _________________________________________________ Python.NET mailing list - PythonDotNet@python.org http://mail.python.org/mailman/listinfo/pythondotnet
-------------------------- Brian Lloyd
brian.lloyd@revolutionhealth.com
participants (3)
-
Brian Lloyd
-
Feihong Hsu
-
Kyle Stevens