How can I successfully reference RestSharp nugget package on console windows service - c#

I have created a console windows service .Net5.0 and now I want to use RestClient and I am getting the below error. From my service, there is a class library called Permit which I have referenced because of some functionality I want, and it is using RestSharp(106.8.0)
This is what I have done to try to fix the problem
From my windows service I have installed the same RestSharp(106.8.0) as the class library(Permit).
Downgraded/upgraded to the lower or higher versions.
Installed RestSharp.CoreNet -Version 106.8.0 / 05.2.4.0(Error:Unable to find package
RestSharp.CoreNet with version (>= 106.8.0))
Besides the above attempts, I still get the same error. How can I solve these conflicts?
Severity Code Description Project File Line Suppression State
Error CS0433 The type 'RestClient' exists in both 'RestSharp.CoreNet, Version=105.2.4.0,
Culture=neutral, PublicKeyToken=null' and 'RestSharp.DotNetCore, Version=105.2.4.0,
Culture=neutral, PublicKeyToken=null' x.Service
C:\Users\x\source\repos\development\x.Service\AuthRepository.cs 58 Active
This is from class library called Permit
This is from console windows service

Related

AddictedCS SoundFingerprinting giving netstandard error

I am attempting to use AddictedCS SoundFingerprinting (https://github.com/AddictedCS/soundfingerprinting).
When I download any recent version and build with Visual Studio 2019 I get the expected output with no errors or warnings (SoundFingerprinting.dll).
The issue is that when I attempt to call functionality from the DLL in a .net console application I get errors relating to netstandard referencing.
I've attempted to add a new reference manually as the error message suggests, but get no further - same error occurs.
Here is my code, taken straight from the SoundFingerprinting example:
var hashedFingerprints = await FingerprintCommandBuilder.Instance
.BuildFingerprintCommand()
.From("C:/Users/Asher/Desktop/testSound.wav")
.UsingServices(audioService)
.Hash();
Here is the error log I am getting when compiling my console app with either mcs or csc:
C:\Users\Asher\Desktop\Raw_0.1>mcs TestProg.cs
-r:SoundFingerprinting.dll -r:protobuf-net.dll TestProg.cs(46,40): error CS0012: The type System.Object' is defined in an assembly that
is not referenced. Consider adding a reference to assembly
netstandard, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=cc7b13ffcd2ddd51'
C:\Users\Asher\Desktop\Raw_0.1\SoundFingerprinting.dll (Location of
the symbol related to previous error) Compilation failed: 1 error(s),
0 warnings
I attempted this on my desktop PC running Windows 10, and on my Surface Pro 6 running Windows 10. I also attempted this using VS2017. The result was the same each time.
Also tried to use the library in Unity3D which caused a crash with no prompt or stacktrace output.
To Reproduce
Use: Windows 10, Visual Studio 2019
Steps to reproduce the behavior:
Download latest release (v7.2.0-beta3)
Build libraries
Attempt to call functionality from SoundFingerprinting.dll via a console application
I encountered exactly the same problem today. What fixed it for me was simply downloading the latest version of protobuf-net from nuget:
Install-Package protobuf-net -Version 3.0.101
Also, please don't paste pictures of code but the code itself next time.

The mysterious "Couldn't not load file or assembly 'System.ServiceModel, Version=4.0.0.0..." error

Scenario: I have a WCF endpoint (endpoint Manufacturing) that connects another WCF endpoint (endpoint DataAPIClient) as ConnectedService. The constructor of an entity in A instantiate the "client" (see below). On top of all these, I have a xUnit test project testing A.
// Manufacturing constructor
public Manufacturing() {
client = new DataAPIClient();
}
// Instantiating in the xUnit project
Manufacturing endpoint = new Manufacturing();
Problem: Something changed (and I couldn't figure out what) that when the test project tries to instantiate Manufacturing. I got this error:
Message: System.IO.FileNotFoundException : Could not load file or assembly 'System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.
I have verified the System.ServiceModel.dll in both endpoints. DataAPIClient has 4.0.30319 and manufacturing has 4.0.0.0.
P.S. I did change the name of the Manufacturing project...not sure if that caused that, but I thought it might be worth of mentioning.
Any help is greatly appreciated...I've been googling and found nothing.
per howcheng's suggestion, I noticed that since I was using xUnit Test Project (.NET Core), I couldn't (or maybe I just didn't know how) add any reference to System.ServiceModel.dll. So I created a Unit Test Project (.NET Framework) and added the xUnit Nugets and System.ServiceModel.dll assembly. The error went away.

Tests for Azure Table Storage using Microsoft.Azure.Storage.Common 9.4.0.2-preview

I created a .NET Standard 2.0 class library where I use Azure table storage as it's described here - https://learn.microsoft.com/en-us/azure/cosmos-db/table-storage-how-to-use-dotnet. Also, I created a .NET Core test project to test my client library. And when I run a simple test I get this:
System.IO.FileNotFoundException : Could not load file or assembly 'Microsoft.Azure.Documents.Client, Version=1.22.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
I tried many things to make it work but this is just waste of time. How do I fix this?
Microsoft.Azure.Documents.Client package is now obselete. Please use Microsoft.Azure.DocumentDB package instead.
Refer here
Nuget Console:
Install-Package Microsoft.Azure.DocumentDB.Core -Version 1.9.1
(Or)
Install-Package Microsoft.Azure.DocumentDB -Version 2.0.0-preview2
See more about this System.IO.FileNotFoundException : Could not load file or assembly error

VS2017 .NetCore 2.0 API - Could not load file or assembly Microsoft.AspNetCore.Hosting.Abstractions

I've just created a new API using ASP.NET Core 2.0.
I haven't coded anything yet. I just want to test the initial API template.
When I try to start my project I receive the following error:
An unhandled exception of type 'System.IO.FileNotFoundException' occurred in Unknown Module.
Could not load file or assembly 'Microsoft.AspNetCore.Hosting.Abstractions, Version=2.0.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
I do not receive any errors when building the project.
The assemby can be found at the following directory: 'C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.hosting.abstractions\2.0.2'.
Is that correct? Where should the 'Microsoft.AspNetCore.Hosting.Abstractions' assembly be located and why can't VS find it?
I had the same error attempting to debug a simple Azure Function App (this is using .NET core) created from the Function App template in Visual Studio 2017. Attempting to run in debugger gave me the same error. It turned out to be I had updated the Microsoft.NET.Sdk.Functions package from version 1.0.6 to 1.0.12. That was my problem. Reverted the update back to 1.0.6 and it worked fine. Hope this helps!
Please re-install the nuget package or upgrade to the latest at: https://www.nuget.org/packages/Microsoft.AspNetCore.Mvc.Abstractions/

XMSFactoryFactory.GetInstance(XMSC.CT_WMQ) returns Fatal error: Failed to initialize XMSFactoryFactory

I'm trying to connect to an IBM message queue using .net and MQ client v8.0.0.5 but I keep receiving the following error:
Fatal error. Failed to initialize XMSFactoryFactory
Could not load file or assembly 'IBM.XMS.Client.Impl, Version=8.0.0.5,
Culture=neutral, PublicKeyToken=d2666ab12fca862b' or one of its
dependencies.
The system cannot find the file
specified.":"IBM.XMS.Client.Impl, Version=8.0.0.5, Culture=neutral,
PublicKeyToken=d2666ab12fca862b
Here's what I've done so far:
Installed MQ Client v8.0.0.5 (x64) on my machine.
Referenced the following assemblies:
amqmdnet.dll
amqmdnsp.dll
amqmdxcs.dll
IBM.XMS.dll
IBM.XMS.Admin.dll
IBM.XMS.Client.Impl.dll
IBM.XMS.NLS.dll
IBM.XMS.Provider.dll
IBM.XMS.Util.dll
Now I also have version v7.5.0.4 installed on my machine and that is having no issues connecting to the queue.
One more thing I noticed is there are no assemblies for v8.0.0.5 in the GAC but the assemblies for v7.5.0.4 are present. Can that be the reason?
Unfortunately, I cannot remove v7.5.0.4 until have both the versions working normally.
Yes, MQ v8.0.0.5 XMS .NET assemblies not being in the GAC is most likely the cause.
You can look at the alternative of using redirection, update app.config file to use the correct version of assemblies your application requires. Look into your MQ installation directory for a file called NonPrimaryRedirect.config. This file contains sample configuration required for application to look for a specific version of MQ/XMS .NET assembly. Copy the contents of this file to your application's app.config file and try. You must ensure all href attributes point to correct path.

Categories

Resources