Could not load file or assembly 'VMware.Binding.WsTrust' - c#

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.

Related

FileNotFound Error while creating SSIS package programmatically using C#

I am trying to write an SSIS package programmatically using C#.
I have installed SQL Server Integration Services Projects v16 and added all the references like Microsoft.SqlServer.ManagedDTS and using Microsoft.Dts.Runtime.
However, at runtime, I am getting an error:
System.IO.FileNotFoundException: 'Could not load file or assembly 'Microsoft.SqlServer.DTSRuntimeWrap, Version=13.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.'
I tried to manually add the DLL "Microsoft.SqlServer.DTSRuntimeWrap" from "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\SSIS\160\Binn" but it throws the same error.
My Microsoft SQL Server Integration Services Projects is version 16.0.5035.3 and hence, I added the reference from the \160\Binn.
However, it seems that the code is asking for another version (Version=13.0.0.0).
Can someone please tell me what's going wrong?
Much appreciated!

Could not load file or assembly 'PdfSharpCore, Version=1.3.40.0

I am using PdfSharpCore version 1.3.40 in a MVC ASP.Net netcoreapp2.1 and it works perfectly on my windows localhost, but when I publish it on a server Linux running Apache the follow exception occurs:
Could not load file or assembly 'PdfSharpCore, Version=1.3.40.0, Culture=neutral, PublicKeyTo ken=null'. The system cannot find the file specified.
I already checked that the PdfSharpCore dll is there, but the system couldn't find it.
Does anyone know what's going on?
We managed to solve the problem, we were forgetting to replace the .deps.json file that contains the dependencies with the new PdfSharpCore.dll dll included in the project. Solved!

Microsoft.CodeAnalysis failed to load file

I have downloaded sample Asp.net project from the git repository and try to build in the local machine VS 2017
below is the error it is showing
Error CS8032 An instance of analyzer
Microsoft.AspNetCore.Mvc.Analyzers.AvoidHtmlPartialAnalyzer cannot be
created from
C:\Users\avinash.nuget\packages\microsoft.aspnetcore.mvc.analyzers\3.0.0-alpha1-10670\analyzers\dotnet\cs\Microsoft.AspNetCore.Mvc.Analyzers.dll
: Could not load file or assembly 'Microsoft.CodeAnalysis,
Version=2.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or
one of its dependencies. The system cannot find the file
specified.. MusicStore E:\LearningTools\sampleapp\MusicStore-master\MusicStore-master\samples\MusicStore\CSC 1 Active
And here is the link for the git repo: https://github.com/aspnet/MusicStore for project reference.
What may be the issue in my machine or any missing file/lib in the framework?
It seems you do not have a dot.Net core SDK installed on your machine. Try installing the SDK and verify.
Thanks,
SK

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

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.

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