Affdex .NET SDK - Could not load file or assembly Affdex or one of its dependencies - c#

I'm having error when running WPF application with reference to C:\Program Files\Affectiva\Affdex SDK\bin\release\Affdex.dll
Exception:
Could not load file or assembly 'Affdex, Version=3.1.1.419, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format."
The WPF application is running under .Net Framework 4.5 and I'm running SDK version downloaded as AffdexSDK-3.1.1-419-win64.exe

According to this Affdex.dll depends on affdex-native.dll and loads it in runtime. Make sure that the latter is accessible to your program by adding it to your %PATH% variable or by adding it to your visual studio project. See example in AffdexMe source code.

Related

Why does using System.Data.Sqlite raise exception Could not load file or assembly 'netstandard, Version=2.1.0.0

I am writing a C# program in Visual Studio 2019 (Windows 10, .Net 4.72). My program uses System.Data.Sqlite. I just copied all the source files from an earlier Windows 7 machine, got it to compile and run, but then I ended up with this message as soon as I reached a line of code that established an SQLConnection:
An unhandled exception of type 'System.IO.FileNotFoundException' occurred in ABC.exe
Could not load file or assembly 'netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.
The program '[4108] ABC.exe' has exited with code -1 (0xffffffff).
I did not use any of the dll's from the previous installation - rather, I used NuGet to download the up-to-date ones. I also downloaded NETStandard.Library.Ref (which contains NetStandard.dll Version 2.1), but it did not work when I tried to install it.
I would use .net 5 or 6, but my program needs a media player, which doesn't seem to be in .Net Core.
Any thoughts would be greatly appreciated.

Could not load file or assembly 'VMware.Binding.WsTrust'

I am trying work with the VMWare SDK to create a Windows service in C# & .NET that automates launching and stopping virtual machines in the VMWare Workstation. I have downloaded the SDK and referenced the necessary dll files in my project.
VimClient c = new VimClientImpl();
ServiceContent sc = c.Connect(serverURL);
UserSession us = c.Login(username, password);
IList<EntityViewBase> vmList = c.FindEntityViews(typeof(VirtualMachine), null, null, null);
I'm attempting to run a basic example but when attempting to connect to the service, I encounter the following exception: "Could not load file or assembly 'VMware.Binding.WsTrust, Version=12.2.0.3593, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified."
When running as a Console Application in .NET Core, I get a similar exception: "Could not load file or assembly 'VMware.System.Private.ServiceModel".
I have tried copying over the runtime dll's from the nuget packages in my user folder and modifying my .csproj file to include these dll's, but I am still encountering the exceptions.
I am using .NET Framework 4.7.2. and my Target OS is Windows 10.
Assemblies added:
InternalVimService50.Wcf
InternalVimService70.Wcf
InventoryService55.Wcf
VimService.dll
VMware.Vim.dll
VmWare.Binding.Wcf
Stack Trace: StackTrace = " at
VMware.Vim.VimClientImpl.CreateClientChannel()\r\n at
VMware.Vim.VimClientImpl.Connect()\r\n at
VMware.Vim.VimClientImpl.Connect(String serviceUrl)\r\n at
VMWareServiceTest.Service1.OnElapsedTime(Object source, ElapsedEventArgs e) in C:\\Users\...
Exception Message:"Could not load file or assembly 'VMware.Binding.WsTrust, Version=12.2.0.3593, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified."
Any help would be greatly appreciated, thank you.
(First post on SO, but regular user of all the wonderful wisdom)
I just had this same issue trying to learn how to interact with vSphere using .Net.
Solved it by building vsphere-ws\dotnet\cs\samples\VMware.Binding.WsTrust from the VMware vSphere SDK, and then adding a refrerence to the resulting dll to my project.
I just loaded the Samples2012.sln in Visual Studio and build that particular project.
Involved versions:
PowerCLI 12.0.0 build 15947286 (Not sure if needed, but this is where I referenced VMware.Vim.dll)
VMware vSphere SDK 6.7U3 (6.7.0-14379537)
Visual Studio 2019 (16.8.2)
.NET Framework 4.8
Windows 8.1
Hopes this helps.

System.IO.FileNotFoundException Error while refrencing a .net standard library inside a .net framework project

I'm getting System.IO.FileNotFoundException error while trying to add a .net standard library into .net framework project's references.
I have created a .net standard project which contains some other .net standard nuggets in its references, and it's output is a dll which I have inserted it as a reference in a .net framework library (actually it is a unit test project for it). But as I told before it always show me this error:
Message: Test method xDetector.Test.IntegreatedTest.TestMethod threw
exception: System.IO.FileNotFoundException: Could not load file or
assembly 'xFramework.NetCore.xDetector, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null' or one of its dependencies. The
system cannot find the file specified.
I have try several ways like editing cproj file and adding other changing visual studio version (which currently is 2019) but no success.
Where the problem may come from?

Referencing library using Windows.winmd

What I'm trying to do
I'm trying to create a library (Arduino.dll) to interact with my Bluetooth device from a laptop (Windows 10). This library is intended to be used by a desktop application.
To achieve that, I had to reference both Windows.winmd and System.Runtime.WindowsRuntime.
What's working
I did write the library and tested it on a console application which was on another project in the same solution. To make it work, I had to reference the project and Windows.winmd in the test project. Note that this test project is used to test all of my libraries, so it is heavily manipulated and I tinkered with the settings a lot for years.
What's not working
I finished to write my dll, and wanted to use it in my desktop application. Therefore, I referenced both Arduino.dll and Windows.winmd as in my test project, expecting to work the same way. Sadly, on running the application, I got a "dll not found" when instantiating a class for Arduino.dll :
An unhandled exception of type 'System.IO.FileNotFoundException' occurred in LuxAFX4.exe
Additional information: Could not load file or assembly 'System.Runtime.WindowsRuntime, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified.
Strange, but well, I tried to reference the (same) System.Runtime.WindowsRuntime as in Arduino.dll but no luck, I now got an even weirder error :
An unhandled exception of type 'System.BadImageFormatException' occurred in LuxAFX4.exe
Additional information: Could not load file or assembly 'System.Runtime.WindowsRuntime, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. (Exception from HRESULT: 0x80131058)
During my search for a solution, I understood that I shouldn't try to load this "reference library" and if it is not found, it must be because it is not installed on the system. But then, why would it work in my test project?
Another thing I may have understand, is that if my library doesn't expose members of referenced 'sub'-libraries, they won't be needed when referencing my library. Should I try to 'hide' all references? If so, is there a way to catch all exposed members? Source : How to to avoid referencing a dll's referenced dll
Side note : I use C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5.1\System.Runtime.WindowsRuntime.dll and C:\Program Files (x86)\Windows Kits\10\UnionMetadata\Windows.winmd.
May be related : Could not load file or assembly Windows.winmd and How to reference Windows.winmd from a .NET Core library?
After some more research, and with the hint given by Hans Passant, I finally understood that I had chosen the wrong System.Runtime.WindowsRuntime.dll to start with. Changing it to use C:\Windows\Microsoft.NET\Framework64\v4.0.30319\System.Runtime.WindowsRuntime.dll instead in both the project with the DLL and the project using it, resolved my problem.
I got the new file location here : C# “await” error when using WinRT from Desktop app

Assembly.GetExportedTypes() does not work in .NET 4.0 (same code runs in 3.5)

Hey guys (and gals) I'm having a problem using Assembly GetExportedTypes() in .NET 4.0. The same code is working perfectly in a project targeted at an older .NET version.
NOTE: *The code works for local assemblies but when trying to open them off a network drive it does not work, that is my problem... It looks to be loading the assembly, but it claims it can't find it when using GetExportedTypes(). Again if I open a dll off my machine it works, this error only occurs with dlls located on network drives *
EDIT: The error is thrown on GetExportedTypes
The Code:
Assembly assembly;
Type[] t;
assembly = Assembly.LoadFrom(dllPathOpenFileDialog.FileName.ToString());
t = assembly.GetExportedTypes();
The Error:
Could not load file or assembly '*..***.***.****, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
(I used asterisks to hide personal information - the file name)
The way certain security policies are handled was changed in .NET 4.0. This article should provide some background.

Categories