1
Unable to load one or more of the requested types.
Problem reported by Naveen - 5/10/2022 at 8:23 AM
Resolved
Getting Exception after installing & configuring Ocelot Library-

Could not load file or assembly 'PresentationEngine, Version=5.9.0.0, Culture=neutral, PublicKeyToken=a6f3cafa178e6038'. The system cannot find the file specified.
Could not load file or assembly 'SpreadsheetEngine, Version=6.4.0.0, Culture=neutral, PublicKeyToken=a6f3cafa178e6038'. The system cannot find the file specified.
Could not load file or assembly 'WordProcessingEngine, Version=6.4.0.0, Culture=neutral, PublicKeyToken=a6f3cafa178e6038'. The system cannot find the file specified.
Could not load file or assembly 'WordProcessingEngine, Version=6.4.0.0, Culture=neutral, PublicKeyToken=a6f3cafa178e6038'. The system cannot find the file specified. 

*Facing this problem in .NET 5 & 6 both versions.  I tried to remove the Gleamtech middleware configuration from Startup but it doesn't work also.

Startup.cs
Services.AddMvc();
services.AddGleamTech(); 
services.AddOcelot(); 


app.UseGleamTech();
app.UseStaticFiles();

await app.UseOcelot();


Please suggest any solution!

5 Replies

Reply to Thread
1
Cem Alacayir Replied
Employee Post
Firstly, if you are not using NuGet and adding DLLs manually, ensure you use netstandard2.0 DLLs (not net40 DLLs,) for .Net Core or .Net 5+ project.

See the below info, you may need to call GleamTechConfiguration.EnsureAssemblies in some cases.

 

Version 5.2.0 - January 9, 2020

  • Added: New GleamTechConfiguration.EnsureAssemblies method which ensures GleamTech's assemblies are loaded and initialized.You may need to call this method in entry point/startup of your application, if you receive "Could not load file or assembly ..." errors.

Some DLLs are embedded inside GleamTech's DLLs and they are resolved automatically when they are requested howeverinternal AssemblyResolver should be initialized first and internal AssemblyResolver of each GleamTech DLL can be initializedonly when a type inside that DLL is accessed first. So in some cases, even a GleamTech DLL is loaded, its AssemblyResolvermay not be initialized yet (because none of its types is accessed yet). You can observe this behaviour if your applicationcalls some methods which scans assemblies for reflection purpose (reflection-only type access does not trigger DLL's module initializer),for example ASP.NET Core's endpoints.MapControllers method and SimpleInjector's RegisterMvcControllers method.So to prevent errors on those methods, you can call this method before such methods.

Note that you should not need to call this method usually for web applications, because it is handled automaticallyas we can know when the application is started by hooking up (automatically in ASP.NET Classic and when you call AddGleamTech andUseGleamTech methods in ASP.NET Core).

 

0
Naveen Replied
  • I did install GleamTech.FileUltimate via Nuget & version is 8.4.2.NETSTANDARD,Version=v2.0
  • Firstly I did install Ocelot(v17.0.1) via Nuget in the project, everything was working well, as soon as I installed Gleamtech.FileUlitmate, project start throwing above error.
  • Could you please create a sample project on .NET 5 with ocelot & Fileultimate & share it with us, it will be very helpfull?

1
Cem Alacayir Replied
Employee Post
Did you call GleamTechConfiguration.EnsureAssemblies as I said? You can call it here:

Services.AddMvc();
services.AddGleamTech(); 
GleamTechConfiguration.EnsureAssemblies();
services.AddOcelot();
0
Naveen Replied
I am so very grateful for your time.
1
Cem Alacayir Replied
Employee Post Marked As Resolution
FYI, with the new Version 8.4.5 - May 11, 2022, you should no longer need to call GleamTechConfiguration.EnsureAssemblies as it will be called early internally in services.AddGleamTech() rather than app.UseGleamTech().

  • Improved: Made GleamTechConfiguration.EnsureAssemblies cached (run-once) and called it first in AddGleamTech
    rather than in UseGleamTech to prevent "Could not load file or assembly" errors when there are plugins like Ocelot
    which scan the assembly usually in ConfigureServices.

Reply to Thread