Problem using .net class in ironpython

If I have a .Net class that is not part of any namespace, then I cannot use it in ironpython.

Here is an example

Suppose I have a FooLib.dll assembly with the following class definition

// note that the following class is not part of the global namespace

public class Foo {}

Now I'm trying to use it in ironpython

clr.AddReference ("FooLib") # This call succeeds.

f = foo ()

String f = Foo () returns an error

Traceback (last last call):

File "", line 1, in

NameError: name 'Foo' not defined

I tried the following

from import FooLib *

f = foo ()

FooLib * , , from ,

, Foo , ironpython

, , .net, , ironpython

Ganesh

+3
1

import :

import clr
clr.AddReference("FooLib") # This call succeeds.
import Foo
f = Foo()
+3

Source: https://habr.com/ru/post/1720313/


All Articles