I am using Windows 7, 64-bit. I have managed to download and install pythonnet, so
import clr
clr.AddReference("System.Windows.Forms")
from System.Windows.Forms import Form
works fine. I have also downloaded and compiled/run a C# application which creates lots of assemblies. The application in question is ARDrone-Control-.NET.
How can I use the generated DLL files from Python (and not just the built-in C# classes).
Since I have never used C# (which is why I want to use the library from Python), I'd be happy to clarify the question.
We can use either a plain text editor (like Notepad) or the IDE's built-in editor. The source code must follow the syntax of the C programming language. After the source file is complete, save it as a *.c file. We'll need a compiler to compile our source code.
In C/C++, the # sign marks preprocessor directives. If you're not familiar with the preprocessor, it works as part of the compilation process, handling includes, macros, and more. It actually adds code to the source file before the final compilation.
The C programming language has been alive and kicking since 1972, and it still reigns as one of the fundamental building blocks of our software-studded world.
In C programming language, %d and %i are format specifiers as where %d specifies the type of variable as decimal and %i specifies the type as integer. In usage terms, there is no difference in printf() function output while printing a number using %d or %i but using scanf the difference occurs.
Just to provide another method:
import sys
sys.path.append("C:\Path\to\your\assemblies")
clr.AddReference('MyAssembly')
from MyAssembly import MyClass
MyClass.does_something()
This assumes that in the C:\Path\to\your\assemblies
folder you have a MyAssembly.dll file.
So the 'trick' is that you have to add your assemblies folder to the sys.path
before clr.AddReference
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With