0

I'm just starting with IronPython and I have some difficulties to use my .NET dll

I've got two assemblies assemblyA and assemblyB, with assemblyA referencing assemblyB. In each assembly, I have a class with this kind of prototyping :

assemblyA

using assemblyB
namespace assemblyA
{
   public classA
   {
      private assemblyB.classB property;
      public assemblyB.classB Property {get;set;}
   }
}

assemblyB

namespace assemblyB
{
   public classB
   {
      private double variable;
      public double Variable{get;set;}
   }
}

In my code, I first load the two assemblies :

import clr
clr.AddReferenceToFileAndPath(r'C:\Users\Me\Documents\.....\assemblyA.dll')
clr.AddReferenceToFileAndPath(r'C:\Users\Me\Documents\.....\assemblyB.dll')
import assemblyA
import assemblyB

clA = assemblyA.classA() #ok
clB = assemblyB.classB() #ok
clA.Prop = clB #Error: expected classB, got classB
clA.Prop = assemblyB.classB() #of course same error

Any suggestion on how to fix the issue ? I guess it is because assemblyB is loaded two times but I only have one assemblyB.dll so why is it not recognized to be the same ?

1 Answer 1

1

After many and many trials, I finally found a solution. I simply add the path where to search for the dll in the system path, and let IronPython decide which one to load :

import sys, os, clr
sys.path.append(r'[MyPath for assemblyA]')
sys.path.append(r'[MyPath for assemblyB]')
clr.AddReferenceToFile('assemblyA.dll')
clr.AddReferenceToFile('assemblyB.dll')

This issue is related to https://ironpython.codeplex.com/workitem/25124 and here I propose a workaround.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.