My ASP.NET application loads an assembly and creates a class instance from an object within it. The assembly itself has a reference to a dll called "Aspose.Cells.dll" which it can access without any problems and is located on the same path as the assembly file itself. However, when I make a method call to one of its methods I get this error:
Could not load file or assembly 'Aspose.Cells, Version=4.1.2.0, Culture=neutral, PublicKeyToken=9a40d5a4b59e5256' or one of its dependencies.
I figure that I need to make my ASP.NET application reference this DLL as well but everything I've tried so far has failed. The assembly DLL which is loaded is not located within the root of the web application and I'm hoping that it doesn't have to be.
I can load the assembly like this:
Assembly asm = Assembly.LoadFile(@"D:\Dev\EasyFlow\Plugins\ImportExportLibrary\bin\Debug\Aspose.Cells.dll");
But I can not use it like this:
AppDomain newDomain = AppDomain.CreateDomain("testAspose");
Assembly asm = newDomain.Load(System.IO.File.ReadAllBytes(@"D:\Dev\EasyFlow\Plugins\ImportExportLibrary\bin\Debug\Aspose.Cells.dll"));
Is there a better way to do it?
Update:
Thanks for your replies.
I forgot to mention that I cannot copy the assemblies to the bin folder or the GAC because I want it to work as a plugin system where assemblies can be replaced easily by changing the path to assemblies in a configuration file and not having to manually copy files into the main project.
However, the AssemblyResolve
event seems interesting and I will give it a try later.