Codebase lists wrong path for referenced assemblies

13 Views Asked by At

I'm having a problem with referenced assemblies. I have a class library that is essentially a plugin for another app. This app looks for plugin .dll files in a Plugins folder. I have structured my files so that all dlls except the main plugin class library dll sit in a subfolder: Plugins\Infoz\lib to keep the root Plugins directory tidy.

Because they are in another locaiton, I load these via:

rootpath = FileOp.CombinePaths(Constants.GameExRootDir, "Plugins\Infoz\lib")

For Each file In Directory.GetFiles(rootpath, "*.dll", SearchOption.TopDirectoryOnly)
    Assembly.LoadFrom(file)
Next

This works fine on my dev machine. However, on the deployment machine, the library runs, but I get the error below the first time I seek to use LiteDB members:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.FileNotFoundException: Could not load file or assembly 'LiteDB, Version=4.1.4.0, Culture=neutral, PublicKeyToken=4ee40123013c9f27' or one of its dependencies. The system cannot find the file specified.
File name: 'LiteDB, Version=4.1.4.0, Culture=neutral, PublicKeyToken=4ee40123013c9f27'

If I look further down the exception text, I see this:

LiteDB
    Assembly Version: 4.1.4.0
    Win32 Version: 4.1.4
    CodeBase: file:///C:/GameEx/PLUGINS/LiteDB.dll

The codebase is listing the wrong file location. Additionally, all other 3rd party dlls have this wrong path.

So I tried to enumerate through all assemblies to show their codebase locations immediately after they are loaded. The aim was to log these on both my dev and deployment machines to see if the ref'd assemblies' codebases are also wrong opn my (working) dev installation. I tried with this code:

Dim a As Assembly = Assembly.GetExecutingAssembly()
For Each aName In a.GetReferencedAssemblies()
    Log.Log_Data("Assembly Code Base: " & aName.Name & " - " & aName.CodeBase)
Next

This successfully lists all of the ref'd assemblies. However, aName.CodeBase is always null.

No issues between the dev and deployment machine in terms of Windows version (both 64bit). The development is on Framework 3.5 (a requirement due to the app being on this version).

I'm totally stuck with how to try and isolate this error further. Any ideas?

0

There are 0 best solutions below