With ServiceStack 3.9.56 cannot find the namespace ServiceStack.ServiceClient.Web - c#

Using NuGet package manager I added the ServiceStack Clients package to a C# project. I tried to add the namespace reference "using ServiceStack.ServiceClient.Web" to a class but the namespace isn't available. I've removed the ServiceStack packages with NuGet, compiled the project and added them again, but the namespace ServiceStack.ServiceClient.Web isn't found.
I have a separate project which uses ServiceStack 3.9.49 and the exact same NuGet packages [ID: ServiceStack.Text & ServiceStack.Common] and the namespace is available in that version.

As this was a new project, I neglected to change the target framework from the client profile to the full/complete profile. Once I made the change, and compiled the app, the namespace was then available. Thanks.

Related

The type or namespace name 'JsonSchema' could not be found

I've just added a nuget package for JSON validation. The docs do not specify how to "import" this package to the project and when I add using JsonSchema.Net the compiler complains The type or namespace name 'JsonSchema' could not be found. What's going on here?
Here's how I added the package.
dotnet add package JsonSchema.Net --version 2.3.0
There isn't a namespace JsonSchema.Net of version 2.3.0 from the GitHub project json-everything of this NuGet source code.
I think you might want to use Json.Schema instead of JsonSchema.Net.
There is a class JsonSchema that might help us do JSON validation.

Unable to use nuget packages

I have written some code that uses the following packages:
using System;
using System.IO;
using System.Reflection;
using Microsoft.Azure.WebJobs;
using Microsoft.Data.SqlClient;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json.Linq;
But when I compile the code there is a few errors related to the following code, that I suppose it is written by the "Microsoft.Data.SqlClient" package:
using Microsoft.Data.Tools.Schema.Sql.UnitTesting;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.Common;
namespace GetDatafromBlob0201
{
[TestClass()]
public class SqlDatabaseSetup
{
[AssemblyInitialize()]
public static void InitializeAssembly(TestContext ctx)
{
// Setup the test database based on setting in the
// configuration file
SqlDatabaseTestClass.TestService.DeployDatabaseProject();
SqlDatabaseTestClass.TestService.GenerateData();
}
}
}
Where "using Microsoft.VisualStudio.TestTools.UnitTesting" throws an error.
I have tried installing the NuGet package, but that didn't solve the error.
These are the errors I get:
Errors after compiling
Mostly CS0246.
The last one indicates that the reference could not be used.
I am also noticing a warning sign under my proyect, on "Packeges" and also on "Assembly":
The one on Assembly its on Microsoft.Data.Tools.Components, Version= 16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL. It doesn't give me details on the warning.
The one on Packages is on Microsoft.Data.Tools.UnitTest and it says: Package 'Microsoft.Data.Tools.UnitTest' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead the project target framework '.NETCoreApp,Version=v3.1'. This package may not be fully compatible with your project.
Test with your csproj file and install any nuget packages, I did not get any build errors.
These are the nuget packages which I have installed.
Microsoft.Data.SqlClient
Microsoft.Azure.WebJobs
Microsoft.Data.Tools.UnitTest
So please make sure that there is no red error lines on your code editor.
Then, close VS, delete .vs hidden folder under the solution folder, bin and obj folder.
After that, restart VS and your project, then, run update-package -reinstall command under Tools-->Nuget Package Manager-->Package Manager Console
Update 1
I think you have created a MSTest test project(net core) project rather than a unit test project(net framework) project.
In my side, I used unit test project(net framework), and all work well.
Actually, some of your nuget packages are for net framework. That is what the warning NU1701 did. But you can ignore that warning since it is normal that you have install the package into net core rather than net framework. And the package can be used under net core. And it is just a little warning rather than a error.
Due to that, update-package -reinstall cannot work for new-sdk project(your situaiton) and only for packages.config with net framework.
Maybe try these:
1)Besides, I think Microsoft.Data.Tools.Components.dll is from C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\Extensions\Microsoft\SQLDB. You have used some dlls from there. And due to some situations, these do not work and you should readd them on your current environment.
And first, please delete any references from here:
Then, readd these dlls from C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\Extensions\Microsoft\SQLDB to check if your project still have these errors.
Or you could remove Microsoft.Data.Tools.Components.dll from there to fix it.
If these do not help, maybe try nuget packages like what I said above:
1) clean all nuget caches first or just delete all files under C:\Users\xxx\.nuget\packages
2) to remove that warning, please add this xml node under csproj file of the unit test project.
3) Or you could try to use unit test project(net framework) project and then add your code there and I ensure that could work.

"SignalR" Doesn't recognize hub

I added all SignalR component but I still have got some errors about dll recognition.
The type or namespace name 'Hub' could not be found (are you missing a using directive or an assembly reference?)
I added following libraries on NuGet;
Microsoft.ASpNet.SignalR
Microsoft.ASpNet.SignalR.Client
Microsoft.ASpNet.SignalR.Core
Microsoft.ASpNet.SignalR.JS
Microsoft.ASpNet.SignalR.OWin
Microsoft.ASpNet.SignalR.SystemWeb
Microsoft.Owin
Microsoft.Owin.Host.SystemWeb
Microsoft.Owin.Security
I think, I don't need most of them.
namespace GenelProject
{
[HubName("gsChat")]
public class ChatHub : Hub
Why Visual Studio doesn't recognize SignalR hub when I want to use it ?
You only need the Microsoft.AspNet.SignalR.Core package. And make sure you have the namespace Microsoft.AspNet.SignalR imported with a using statement in your file.
please right click on your project and select manage Nuget Packages then in Installed tab find Microsoft.ASPnet.signalR press uninstall. then try installing it again.

The type or namespace IAppBuilder could not be found(missing using a directive pr an assembly reference)

I am working on an Asp.Net MVC 4 Application in which I am using SignalR 2.0.1 and I Mapped it using Owin Startup class and it worked fine at first.
All of a sudden when I tried to rebuild my app it said that the type are namespace IAppbuilder could not be found.
Following is my start up class
using Microsoft.Owin;
using Owin;
using WhiteBoardApp;
namespace WhiteBoardApp
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
app.MapSignalR();
}
}
}
I have installed Owin package too, and for some reasons I could not find Owin Startup class so I just added a normal class and included all the references that are needed.
May I know where I am making a mistake
Try to use Package Manage Console and do
Update-Package Owin -Reinstall
I was having similar issue. But instead Owin, problem was causing Microsoft.Owin, obviously
Update-Package Owin -Reinstall
Didn't work, neither did Update-Package Owin
BUT
Install-Package Microsoft.Owin
did work fine for me, thanks.
The IAppBuilder interface is found under Owin package. Just add a reference in your class file:
using Owin;
And rebuild. Your project will pick this up.
I have no idea why VS didn't pick this up, but it didn't. Once I added this reference to my project, then everything fell into place.
I encountered the same problem while building my project. Here are the steps that helped fix my problem:
Go to Solution Explorer and look for your project
Under your project, expand the References; You should see warnings on the problematic reference
Right click References and open Manage NuGet Packages
Search the name of problematic reference i.e. Microsoft.Owin; After loading it shows that it is already installed (It is, but it installed incorrectly. Checking the properties > version at step 2 shows 0.0.0.0)
Check Force uninstall, even if there are dependencies on it
Uninstall
Install
Build and run the project
Problems
Cannot install Microsoft.Web.Infrastructure because it already exists in the packages folder. Rolling back...
Go to your project folder and look for packages
Find the problematic package i.e. Microsoft.Web.Infrastructure
Delete the folder
Resume from step 7
Alternatives
Here are the alternatives I've read about to fix this kind of problem.
Clean and Rebuild Project / Solution
Restart Visual Studio
Restart PC
Good luck.
My Visual Studio 2013 for some reason didn't realize that the references paths existed. The yellow exclamation mark in front of the references was shown for all the added packages. I checked ../packages/ but all files existed, i also opened the .csproj file which referenced the correct paths.
Closing and opening the solution returned quite a lot of errors, and could not load the projects included in the solution.
Restarting Visual Studio 2013 saved the day for some unexplained reason.
My following using's equivalent in F# present a problem of hiding the IAppBuilder. It turns out that the Owin stipulation was being interpreted as an incomplete System.Web.Http.Owin reference, even though the Owin.dll providing the Owin namespace was referenced.
open System.Net.Http
open System.Web.Http
open Microsoft.Owin
open Owin
The problem was resolved by rearranging the usings as follows:
open Microsoft.Owin
open Owin
open System.Net.Http
open System.Web.Http
...granted, this may be a bug peculiar to the F# compiler and name conflicts are handle better in C# and elsewhere.
In my case, I had moved around the project folders and the location of the vs solution file (.sln). Once I was done with re-adding the projects, there was a packages folder on the solution level and one was left in a project sub folder.
This way, in that project, the relative package folder links in the .csproj file got messed up.
The reinstallation or other tips regarding the nuget package manager in this thread were helpful. I noticed, that after I reinstalled a few packages, in my git source code diff, the path of the packages folder was changed within the csproj file.
Before
<HintPath>packages\Microsoft.Owin.4.0.1\lib\net45\Microsoft.Owin.dll</HintPath>
After
<HintPath>..\packages\Microsoft.Owin.4.0.1\lib\net45\Microsoft.Owin.dll</HintPath>
So, if you run in the same issue and you have a lot of nuget packages, it might be easier to close the whole solution, open the csproj file(s) in a text editor like vscode and fix the relative links with search and replace. Then just save, close, reopen solution in VS and restore nuget packages. That should do the trick.
(In any case, you should delete the local packages folder on the project level, so that the project really fails, if it does not get the right packages.)
It's an ordering issue.
using Microsoft.Owin;
using Owin;
Leads to Microsoft.Owin to be defined first, then Owin is found under already imported Microsoft namespace. If you mouse over Owin of using Owin you should see it was resolved to Microsoft.Owin again and furthermore IDE will gray out using Owin as redundant unused reference.
Do:
using global::Owin;
Which clarifies for the compiler not to look for Owin under already defined namespaces (e.g. Microsoft. namespace).
http://www.asp.net/signalr/overview/getting-started/tutorial-getting-started-with-signalr
Check for the visual studio you are using
You can find the following comment
Note: If you are using Visual Studio 2012, the SignalR Hub Class (v2) template will not be available. You can add a plain Class called ChatHub instead.
Also
Note: If you are using Visual Studio 2012, the OWIN Startup Class template will not be available. You can add a plain Class called Startup instead.

The type or namespace name 'Http' does not exist?

I have this portable class library, its settings it Windows Phone 8, Windows Store and .NET 4.5.
I'm trying to add the HttpClient, but after I add it by NuGet its runtime version is v4.0.30319, and when i try to using System.Net.Http it states:
The type or namespace name 'Http' does not exist in the namespace 'System.Net' (are you missing an assembly reference?)
The following is added as a reference, and was added by NuGet upon install:
System.Net.Http
System.Net.Http.Extensions
System.Net.Http.Primitives
The class I'm trying to use is HttpClient in my portable class library :-/
This MSDN blog post makes it clear that you need to use this special release of HttpClient.
To use the HttpClient package, right click on your solution, go to the
Manage Nuget Packages dialog, search for Id Microsoft.Net.Http, and
make sure “Include Prerelease” is turned on.
This was released last February, but I haven't seen any updates to indicate that it is now obsolete.
EDIT
Here's the page for the latest version of this package

Categories

Resources