I recompiled using .NET 2.0 and now I can load the DLL. Is there any support for frameworks after 2.0? I'd hate to lose the ability to use LINQ.
Also, you mentioned Python.Runtime.dll.config. I don't have this file. What's in it?
thanks for your help
When you import the assembly it will be referenced by the assembly name defined in the project settings (which is what the dll will be named as). GAC isn't required ( i never do that ).
I just did a quick test here. Made an empty Class project via Visual Studio 2008.
Then tweaked the source to add 2 functions:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ClassLibrary1
{
public class Class1
{
public string Function1()
{
return "Test Function Called";
}
public void Function2()
{
Console.WriteLine("Hello World");
}
}
}
I built it with all default settings (as a class library), then copied the dll to the python / lib / site-packages folder, along with the clr.pyd, Python.Runtime.dll and Python.Runtime.dll.config files
Then from python:
Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import clr
>>> clr.AddReference('ClassLibrary1')
<System.Reflection.Assembly object at 0x01DF5580>
>>> import ClassLibrary1
>>> myObject = ClassLibrary1.Class1()
>>> myObject.Function1()
u'Test Function Called'
>>> myObject.Function2()
Hello World
>>>
Note that the "import ClassLibrary1" is the namespace not the assembly (it just happens to be the same since its all default values).
I wonder if your issue is somehow related to VS2010? Could it be adding some default references? What references are listed in VS?
cheers,
laszlo
On 14/12/2010 5:47 PM, Jason Awbrey wrote:
Thanks. I tried creating a test assembly with just a default constructor and no other dependencies, and I get the same error when I try to import it.
I also tried setting the path variable, through windows as well as in code, and get the same result.
Assuming my dll is named "TestLib.dll", I should be able to do clr.AddReference("TestLib"), correct?
Do I have to strong name my assemblies, or put them in the GAC? Or is that optional?
Any other suggestions of how to track this down?
_________________________________________________
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet