I'm trying to load a DLL from SysWOW64 on a C# application. The DLL in question is "nvEncodeAPI.dll", which is an nVidia h264 encoder that I am planning to use on a future application.
Here is my code:
string filePath = Environment.ExpandEnvironmentVariables("%windir%");
if (!filePath.Trim().EndsWith(@"\"))
filePath += @"\";
filePath += @"SysWOW64\nvEncodeAPI.dll";
try
{
Assembly assem = Assembly.LoadFile(filePath);
}
catch (BadImageFormatException e)
{
Console.WriteLine("Unable to load {0}.", filePath);
Console.WriteLine(e.Message.Substring(0,
e.Message.IndexOf(".") + 1));
}
The exception actured is indeed a BadImageFormatException with the message as follows:
Message = "The module was expected to contain an assembly manifest. (Exception from HRESULT: 0x80131018)"
I have tried:
User contributions licensed under CC BY-SA 3.0