How to load our own dll written with the revit api in the RevitPythonShell

How to load our own dll written with the revit api in the RevitPythonShell

Anonymous
Not applicable
1,411 Views
2 Replies
Message 1 of 3

How to load our own dll written with the revit api in the RevitPythonShell

Anonymous
Not applicable

I have written a dll with the revit Api. 
There a simple function doSomethingToAElement

I want to use this function on a element

I have written
import clr  # OK
... clr.AddReference('C:\\Users\\user040\\Project\\myDll.dll')

And I have this problem

 

Exception : System.IO.FileLoadException: The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)
   at System.Reflection.AssemblyName.nInit(RuntimeAssembly& assembly, Boolean forIntrospection, Boolean raiseResolveEvent)
   at System.Reflection.AssemblyName..ctor(String assemblyName)
   at System.Reflection.Assembly.LoadWithPartialName(String partialName)
   at IronPython.Runtime.ClrModule.LoadAssemblyByPartialName(String name)
   at IronPython.Runtime.ClrModule.AddReference(CodeContext context, String name)
   at IronPython.Runtime.ClrModule.AddReference(CodeContext context, Object[] references)
   at Microsoft.Scripting.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
   at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
   at Microsoft.Scripting.Interpreter.LightLambda.Run4[T0,T1,T2,T3,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3)
   at System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2)
   at Microsoft.Scripting.Interpreter.DynamicInstruction`4.Run(InterpretedFrame frame)
   at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
   at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1)
   at IronPython.Compiler.PythonScriptCode.RunWorker(CodeContext ctx)
   at Microsoft.Scripting.Hosting.ScriptSource.Execute(ScriptScope scope)
   at Microsoft.Scripting.Hosting.ScriptSource.ExecuteAndWrap(ScriptScope scope, ObjectHandle& exception)

Though this dll has compiled and is used already used for revit addin.

0 Likes
Accepted solutions (1)
1,412 Views
2 Replies
Replies (2)
Message 2 of 3

jeremy_tammik
Alumni
Alumni

Maybe this message is trying to tell you:

 

"The assembly you are attempting to load is referencing some other assembly and has trouble resolving that reference."

 

What assemblies does myDll.dll reference?

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 3 of 3

Anonymous
Not applicable
Accepted solution

I replace AddReference with AddReferenceToFileAndPath. Now its working.
Thanks for you help

0 Likes