3rd party dll in Revit Addin

3rd party dll in Revit Addin

Anonymous
Not applicable
3,809 Views
7 Replies
Message 1 of 8

3rd party dll in Revit Addin

Anonymous
Not applicable

Hi,

 

I have a Revit Addin developed. I referenced a 3rd party dll (no source code that assembly). When I run the Revit plugin it throws me a "System.IO.FileNotFoundException: Could not load file or assembly 'Esri.FileGDBAPI.dll' or one of its dependencies. The specified module could not be found." error. Can someone help me how to overcome this. Thanks.

 

Arun Raj

0 Likes
3,810 Views
7 Replies
Replies (7)
Message 2 of 8

MarryTookMyCoffe
Collaborator
Collaborator

put your loacal reference dll in the same folder you put your app dll.

 

-------------------------------------------------------------
--------------------------------|\/\/|------------------------
do not worry it only gonna take Autodesk 5 years to fix bug
0 Likes
Message 3 of 8

Anonymous
Not applicable

Hey.. thanks for the response. I did that but with no success. I copied the my custom dll into C:\Program Data\Autodesk\Revit\Addinns\2018\ folder along with the addin and its assembly. still no success. Have you ever referenced any custom dll ? btw I am using 64 bit version of my custom dll.

0 Likes
Message 4 of 8

MarryTookMyCoffe
Collaborator
Collaborator

I have my own custom libbray for revit adn i use sqlite.
I hade a little problem with sql but it was in the end problem with file not in right place.


1)see if you have set reference as local.
2)look on App.config. See if your dll  is there.

3)in the end you can try to remove reference (or nuget, don't know from where you get it) and add it again

-------------------------------------------------------------
--------------------------------|\/\/|------------------------
do not worry it only gonna take Autodesk 5 years to fix bug
0 Likes
Message 5 of 8

mattmas
Enthusiast
Enthusiast

Whenever I have to use a referenced DLL in my addin, I generally setup an AssemblyResolve event to tell .NET where to find the DLL in question.

(this is because .NET does not automatically load from the same location as your DLL - it automatically loads from the same location as REVIT.EXE).

 

See Jeremy's notes here:

http://thebuildingcoder.typepad.com/blog/2014/05/rvtva3c-assembly-resolver.html

 

Good Luck,

Matt

 

Message 6 of 8

MarryTookMyCoffe
Collaborator
Collaborator

thx for this info. didn't knew about it, now I'm surprised that my app work.
I look on place where revit.exe is and I have a System.Data.SQLite.dll, but how it get there ? if i didn't put it there ? or maybe revit had it already?

 

-------------------------------------------------------------
--------------------------------|\/\/|------------------------
do not worry it only gonna take Autodesk 5 years to fix bug
0 Likes
Message 7 of 8

mattmas
Enthusiast
Enthusiast
Revit does use SQLite in a number of different ways, so yes, that's possible.
0 Likes
Message 8 of 8

premmuru
Explorer
Explorer

I faced this problem when loading a 3P assembly by referencing it in XAML (using WPF). Other 3P .dll files which are imported using using statements loads fine without any problem but the ones referred through XAML, Revit is only searching install location. I followed the above advice from mattmas and included this code in my ExternalCommand to add my addin folder where my .dll files are copied to and it works!

 

AppDomain currentDomain = AppDomain.CurrentDomain;
currentDomain.AssemblyResolve += new ResolveEventHandler(LoadFromSameFolder);

static Assembly LoadFromSameFolder(object sender, ResolveEventArgs args)
{
    string folderPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
    string assemblyPath = Path.Combine(folderPath, new AssemblyName(args.Name).Name + ".dll");
    if (!File.Exists(assemblyPath)) return null;
    Assembly assembly = Assembly.LoadFrom(assemblyPath);
    return assembly;
}

 

https://stackoverflow.com/questions/1373100/how-to-add-folder-to-assembly-search-path-at-runtime-in-...