I have some types in a C# library I wrote, e.g.:
namespace SprocGenerator.Generators
{
public class DeleteGenerator : GeneratorBase
{
public DeleteGenerator(string databaseName, string tableName) : base(databaseName, tableName)
I want to use them in an IronPython script:
import clr
import sys
clr.AddReferenceToFile("SprocGenerator.dll")
# problem happens here:
from SprocGenerator.Generators import *
generator = DeleteGenerator("a", "b")
When the line below the comment happens, I get:
ImportError: No module named Generators
I have verified that the file I am loading is what I expect by renaming it and verifying the script throws an error when trying to load the assembly. I have verified the namespace is in the assembly via Reflector. I have also tried specifying a fully-qualified classname to work around my import issue, e.g.
generator = SprocGenerator.Generators.DeleteGenerator("a", "b")
But I get:
NameError: name 'SprocGenerator' is not defined
Even if I have this in C#:
namespace SprocGenerator
{
public static class GeneratorHelper
{
public static string GetTableAlias(string tableName)
And this in IP:
import clr
import sys
from System import *
clr.AddReferenceToFile("SprocGenerator.dll")
from SprocGenerator import *
print "helper = " + GeneratorHelper.GetTableAlias("companyBranch")
I get this error:
NameError: global name 'GeneratorHelper' is not defined
What am I doing wrong?