Adding External Reference throws Dependency Exception

SyntaxEditor for Windows Forms Forum

Posted 4 years ago by Jose Gomez
Version: 14.1.0323
Avatar

Hi All,

Trying to load an external refernece that itself has some dependencies

dotNetProjectResolver.AddExternalReference("MyDll");

 

Throws the following exception

"System.ApplicationException: Could not load exported type data for assembly 'Ice.Lib.EpiClientLib, Version=3.0.7.0, Culture=neutral, PublicKeyToken=5d3fa3c7105d7992'. ---> System.IO.FileLoadException: Cannot resolve dependency to assembly 'Infragistics4.Win.v12.2, Version=12.2.20122.2018, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb' because it has not been preloaded. When using the ReflectionOnly APIs, dependent assemblies must be pre-loaded or loaded on demand through the ReflectionOnlyAssemblyResolve event.\r\n at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)\r\n at System.Reflection.RuntimeAssembly.GetExportedTypes()\r\n at #Rye.#eze..ctor(Assembly assembly, String assemblyFullName, String assemblyLocation, String cachePath, Boolean documentationEnabled)\r\n --- End of inner exception stack trace ---\r\n at #Rye.#eze..ctor(Assembly assembly, String assemblyFullName, String assemblyLocation, String cachePath, Boolean documentationEn
abled)\r\n at ActiproSoftware.SyntaxEditor.Addons.DotNet.Dom.AssemblyCodeRepository.#2ye.#BGe(AssemblyCodeRepositoryOptions #qgb, ResolveEventHandler #B1f)\r\n at ActiproSoftware.SyntaxEditor.Addons.DotNet.Dom.AssemblyCodeRepository.#2ye.#BGe(AssemblyCodeRepositoryOptions #qgb, ResolveEventHandler #B1f)\r\n at ActiproSoftware.SyntaxEditor.Addons.DotNet.Dom.AssemblyCodeRepository.Add(String assemblyName, DotNetProjectResolver projectResolver)\r\n at ActiproSoftware.SyntaxEditor.Addons.DotNet.Dom.DotNetProjectResolver.AddExternalReference(String assemblyName)\r\n at AppAutoComplete.Form1.button1_Click(Object sender, EventArgs e) in c:\\Users\\jose\\Documents\\Visual Studio 2013\\Projects\\AppAutoComplete\\AppAutoComplete\\Form1.cs:line 57"

 

Which i thought I could get fixed by loading the dependent Assembly First

dotNetProjectResolver.AddExternalReference("DLLMYDLLDEPENDSON");

dotNetProjectResolver.AddExternalReference("MYDLL");

 

But although the initial DLL loads ok, whe MyDLL tries to load it still complains about not having the dependency (that I previously loaded)

Any ideas?

Comments (4)

Posted 4 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Jose,

The assemblies load in a separate temporary AppDomain so that's why it doesn't necessarily matter if you referenced other ones already. 

If you are having trouble with assembly resolution, you could use the overload of DotNetProjectResolver that accepts a ResolveEventHandler.  When you pass that in, it will be used instead of our default one, allowing you to have full control over the resolution process.


Actipro Software Support

Posted 4 years ago by Jose Gomez
Avatar

Thanks! I just tried this and my handler isn't getting called... am I missing something? It is still throwing an exception when loading my EpiClientLib and my handler isn't being invoked.

 

public void SetupEditor()

{

SemanticParserService.Start();
dotNetProjectResolver = new DotNetProjectResolver(CurrentDomain_AssemblyResolve);
dotNetProjectResolver.CachePath = @"C:\Temp";
dotNetProjectResolver.AddExternalReferenceForMSCorLib();
dotNetProjectResolver.AddExternalReferenceForSystemAssembly("System");
dotNetProjectResolver.AddExternalReferenceForSystemAssembly("System.Data");
dotNetProjectResolver.AddExternalReferenceForSystemAssembly("System.Drawing");
dotNetProjectResolver.AddExternalReferenceForSystemAssembly("System.Windows.Forms");
dotNetProjectResolver.AddExternalReference(@"E:\Epicor Installs\E10.700.2\Client\Ice.Lib.EpiClientLib.dll");
CSharpSyntaxLanguage cSharpLanguage = new CSharpSyntaxLanguage();
syntaxEditor1.Document.Filename = "BaseControl.cs";
syntaxEditor1.Document.Language = cSharpLanguage;
syntaxEditor1.Document.LanguageData = dotNetProjectResolver;

}

Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
       return Assembly.LoadFrom(@"E:\Epicor Installs\E10.700.2\Client\Infragistics4.Win.v12.2.dll");
}

Posted 4 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

I would think that what you have would work in general.  Looking over our code, it also does appear that when setting up the AppDomain for assembly loading, we add the paths of all previous external references to the app domain's PrivateBinPath.  So based on that, adding the dependecy assembly first would allow the second one to find it.

If you'd like us to look into it further, please make a new very simple sample project that we can debug the issue with and email it to our support address.  Please reference this thread and rename the .zip file extension of what you send so it doesn't get spam blocked.  Thanks!


Actipro Software Support

Posted 4 years ago by Jose Gomez
Avatar

I submited the request,

 

Thanks!

The latest build of this product (v2018.1 build 0341) was released 9 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.