Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
Anonymous
1109 Views, 2 Replies

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

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.

2 REPLIES 2
Message 2 of 3
jeremy_tammik
in reply to: Anonymous

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
Message 3 of 3
Anonymous
in reply to: jeremy_tammik

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report