Error message 'Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.'
I solved this issue by setting the Copy Local attribute of my project's references to true.
Entity Framework LoaderExceptions Unable to load one or more of the requested types
As the top line of the stack says:
Retrieve the LoaderExceptions property for more information.
You can find this by examining the exception in the debugger.
ReflectionTypeLoadException Unable to load one or more of the requested types
I had the exact same issue but the Assembly it was having issues with I didn't really care about.
I went from this (worked locally):
Type t = AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(a => a.GetTypes())
.Where(a => a.FullName == clientEx.ExceptionType)
.FirstOrDefault();
To this:
Type t = null;
foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies())
{
try
{
foreach (Type type in a.GetTypes())
{
if (type.FullName == clientEx.ExceptionType)
{
t = type;
break;
}
}
if (t != null)
break;
}
catch (Exception) { }
}
System.Reflection.ReflectionTypeLoadException: 'Unable to load one or more of the requested types. Could not load file or assembly
So in my case the dll file Crijoya.Core was in a different format as the error says. After trying everything they said on other questions this is what worked for me.
I have a project with two class libraries like so
I made sure that in the properties of each of them the platform was Any CPU
And finally that on Tools I was using the 64 bit version for IIS Express for web projects
Azure table: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information
Is there a way to look at the LoaderException stacktrace.
You could use StackTrace class to trace exception in your project.
Or you could retrieve ReflectionTypeLoadException.LoaderException property to get more information about LoaderException.
Catch the exception in Code:
try
{
// load the assembly or type
}
catch (Exception ex)
{
if (ex is System.Reflection.ReflectionTypeLoadException)
{
var typeLoadException = ex as ReflectionTypeLoadException;
var loaderExceptions = typeLoadException.LoaderExceptions;
}
}
At the moment, Under Property of the Project, Application -> Target Framework is running in .netStandard 2.0
Just some features in trigger types could use in Azure function v2 preview template:
For example, the BlobTrigger supports fine in v2. You could have a try to operate azure storage.
Create Azure function v2 preview:
Create BlobTrigger:
The Code in BlobTrigger:
public static class Function1
{
[FunctionName("Function1")]
public static void Run([BlobTrigger("helloworld/{name}", Connection = "AzureWebJobsStorage")]Stream myBlob, string name, TraceWriter log)
{
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
"storage account connection string");
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer container = blobClient.GetContainerReference("helloworld");
CloudAppendBlob blob = container.GetAppendBlobReference("log2.txt");
using (var fileStream = System.IO.File.OpenRead(@"D:\log.txt"))
{
blob.UploadFromStreamAsync(fileStream);
}
log.Info($"C# Blob trigger function Processed blob\n Name:{name} \n Size: {myBlob.Length} Bytes");
}
}
The result in BlobTrigger:
So you'd better to choose the compatible platform version. More details please refer this article.
Azure Functions runtime 2.0 is in preview, and currently not all features of Azure Functions are supported.
Getting Error: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information
Needed to change ajax 4.5 to 4.0. and worked.
C# - Loading DLL Dynamic - System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types
Solution to the problem was quite easy. It is just using a different method from the assembly. Instead of using LoadFile
, we should use LoadFrom
So the below code solves the problem efficiently
var assembly = Assembly.LoadFrom(assemblyInfo.FullName); // loads perfectly, absolute path to dll
var types = assembly.GetTypes(); // loads perfectly.
There is no need to use GetExportedTypes. We can get all the types.
LoadFrom does auto reflection binding with other DLLs, however, loadfile doesn't do the same.
Which resolves that export issue.
Related Topics
Mono High Resolution Timer (On Linux)
How to Get and Set Environment Variables in C#
How to Turn a Datatable to a CSV
How to Create a .Net Datetime from Iso 8601 Format
Cannot Delete Directory with Directory.Delete(Path, True)
Differencebetween a Shared Project and a Class Library in Visual Studio 2015
Prevent Caching in ASP.NET MVC for Specific Actions Using an Attribute
Detect If Running as Administrator with or Without Elevated Privileges
How to Get Dropdownlist Selectedvalue in Controller in MVC
Generic Repository or Specific Repository for Each Entity
Loading Custom Configuration Files
Windows 10 Universal App File/Directory Access
Linq - Left Join, Group By, and Count
How to Get JSON.Net to Serialize Members of a Class Deriving from List<T>