I read about Web API having its own TraceWriter implementation with 2012.2, for example here, among other sources.
I am now using VS2013 with .NET 4.5.1 and the EnableSystemDiagnosticsTracing is nowhere to be found. It's meant to be defined in the HttpConfigurationTracingExtensions class which resides in the System.Web.Http.Tracing.dll. However, this assembly is nowhere to be found - not in list of assemblies in the Add Reference dialog, not in GAC.
Where is this assembly supposed to come from? Docs say it's part of .NET Framework 4, which I have installed. Also installed the ASP.NET Web API 2 Tracing 5.0.0 NuGet package. Is there some update? Should I re-install .NET Framework?
I know it's not a big deal to implement ITraceWriter myself but it bothers me not to know what happened with the built-in implementation.
Just install needed NuGet Package
Install-Package Microsoft.AspNet.WebApi.Tracing -Version 5.0.0
It's a little bit strange, but it is the right package
http://www.nuget.org/packages/microsoft.aspnet.webapi.tracing
If you installed the Tracing 5.0.0 NuGet package, it should be correctly included in your project. The moment it is installed, I believe a separate text file should open in VS showing the code you should include in your WebApiConfig.cs file.
I haven't created a Web API 2 project from scratch (only upgraded from pre-5.0 to 5.0 projects), but this is the code that should reside in your WebApiConfig.cs file:
// To disable tracing in your application, please comment out or remove the following line of code
// For more information, refer to: http://www.asp.net/web-api
config.EnableSystemDiagnosticsTracing();
And that should be it, if the package is installed correctly, tracing should now be used in your project.
Related
I have a solution with a number of projects.
I have changed system.Net.http to use the NuGet version, and most projects, when i select the "System.Net.Http" reference in the references node of solution explorer, it shows the path as "X:\myPath\packages\System.Net.Http.4.3.4\lib etc..."
However, i have a couple of projects when removing reference to System.Net.Http then going to NuGet Package Manager and installing it, when you click reference in the reference node, the path shows as "C:\Program Files etc.... Microsoft.NET.Build.Extensions\net461\"
I have opened the project file, and the "HintPath" is correct, however the path that shows in the reference Properties is incorrect.
When i look at Object Browser, it confirms this project is actually calling the framework version of System.Http.Net (so, even though i have installed NuGet version, and the HintPath is pointing to our packages folder, its still referencing the framework version)
Does anyone know why the path isnt matching and how I can fix this (so my project is using NuGet version instead of framework version to match the other projects in my solution?
Just incase it helps, here are all the references in the problem project:
I have a theory: it's a hack implemented in Visual Studio in order to workaround an issue with the package System.Net.Http.
There are issues with this package and it seems we should not use it anymore. The version of the System.Net.Http library included in the .NET Framework is better starting from 4.7.2 if I understand correctly.
See:
https://github.com/dotnet/corefx/issues/11100
https://github.com/dotnet/corefx/issues/17522#issuecomment-338418610
https://github.com/dotnet/corefx/issues/29622
I'm currently moving projects to .NET Framework 4.8 and I'm removing all System.Net.Http packages.
The NuGet.Server package is used to create a ASP.NET MVC NuGet server and it works just fine. There is another package NuGet.Server.Core that is expected to do the same when hosted within a ASP.NET Core (perhaps 1.0 or 1.1?).
The first one creates 'Packages' folder right beneath the main folder used as a package repository.
No such things happens after installing the Core version. I tried both root and a dedicated folder. Googling a bit, I found no info about installing the package and integrating it in a ASP.NET Core app.
Has anyone succeeded in installing the Core version? Also, there's another version NuGet.Server.V2 which depends on NuGet.Server.Core, however it requires .NET Framework 4.6.1. This makes me think that NuGet.Server.Core is not targetting .NET Core at all.
If so, the name must be somewhat misleading, I guess...
Yes, this is the answer:
No .NET Core whatsoever! Just .NET Framework 4.6.1. Not a big discovery but a warning to all devs who, like me, were (and, more importantly, will be!) misled by 'Core' in the package's name.
Here's a 3rd party option (free)
https://github.com/loic-sharma/BaGet
Nuget.Server.Core seems to be one of the dependencies of Nuget.Server. So it's not a .NET Core project. Guess that's one of those snags you run into when you call your framework "Core". :)
I think you can use BaGet.
There is my article about that.
Check this :
Create your own NuGet server and package feed
I am trying to install SwashBuckle to an ASP.NET 5 Web API application.
The problem comes during installation where I get the following error:
This is due to the fact that the package is only partly compatible with DNX Core 5, specifically WebActivatorEx which is installed under DNX 4.5.1 and as such the SwashBuckle dll can't get at it as that is installed under DNX Core 5.
Following this answer, I moved both dlls under DNX 4.5.1 as suggested:
This has meant that the solution now builds, however I don't see any of the config add to StartUp.cs to enable and register Swagger. I have been trying to piece this together from examples for ASP.NET 4.5.1 but to no avail.
All I am currently seeing when I browse to http://MyApi/Swagger is a blank screen.
Can anybody let me know how I can register swagger with my API correctly?
Just Add
Blockquote
"Swashbuckle": "6.0.0-beta9"
Blockquote
To your Dependencies in the project.json file. Save the Project.json file and let the NPM Restore do its thing. Not sure why the other lower Stable builds don't work but this one does.
This problems is nagging me from last night ,I can't figure out its solution.
Well let me explain the structure of my project,In a single solution file I have three projects two are asp.net mvc 4 projects and one in C# Library,the problem started when I added new asp.net mvc 4 project.
I have tried several solutions ,but they didn't worked for me,
nuget restore (first I deleted the whole package folder then applied
nuget restore).
Tried uninstalling asp.net web optimization package then
webgrease and then installed them both.
Tried cleaning temp folder of asp.net.
Removed xmlns from web.config assemblyBinding tag
Note:
By using the first solution I was able to fix the problem on my home dev machine,but the same solution doesn't works on my office dev machine :(
I have also discussed this problem on asp.net chat before posting question here.
Assembly binding log aka FusionLog Viewer
tried several SO solutions.
Update:
Moved the two MVC4 webapp in seperate solutions,so one solution is
working fine but another is having same webgrease problem.
Solution:
Check my answer below for the solution which worked in my situation.
If your solution it's for 64-bit and the dll-s are for 32 bit, go to:
IIS / Application Pools
Right click your website app pool / advanced settings
Set 'Enable 32-bit Applications' to TRUE
Hi guys,
So I merged my both solutions,now both mvc4 projects along with a test case project and C# Class library project are in the same solution.
I finally made it work for me,here are the steps with the nuget console commands
uninstall-Package Microsoft.AspNet.Web.Optimization
uninstall-Package webgrease
Install-Package Microsoft.AspNet.Web.Optimization -Version 1.1.0
Note:
I was having WebGrease 1.5.2 and Microsoft.AspNet.Web.Optimization 1.1.3 in my project and I had to rollback to earlier version to make it work.
I have a Web API that has version 5.1.2 of the Microsoft.AspNet.WebApi.Client package installed.
I am trying to access the API from an ASP.NET MVC application, which also has the same version of the package installed.
However, in the Global.asax of the Web API project, on the line below, I get the following exception:
WebApiConfig.Register(GlobalConfiguration.Configuration);
Attempt by method 'System.Web.Http.HttpConfiguration..ctor(System.Web.Http.HttpRouteCollection)' to access method 'System.Web.Http.HttpConfiguration.DefaultFormatters()' failed.
I found that this error occurs when you have multiple projects pointing to different .net versions.
For example if you have a Web API project targeting .net 4.5 and a unit test project targeting .net 4.5.3 it seems that default settings mean nuget may silently update the .net 4.5 project references to incompatible versions one day when you open visual studio and cause your Web API project to fail with the recondite 'Attempt by method 'HttpConfiguration..ctor(HttpRouteCollection)' to access method 'HttpConfiguration.DefaultFormatters()' failed' error.
To avoid the error drop the higher .net version back on the new project to match the Web API project - for this example right click the unit test project, click properties, then change the target framework to .net framework 4.5.
In my case it was a discrepancy between versions of Microsoft.AspNet.WebApi.Client and Microsoft.AspNet.WebApi.Core, I tried updating both to the same version and it worked.
In my case, the issue was solved when I installed the Microsoft.AspNet.WebApi.Core as well. So three libraries should present and be in harmony (uninstall / install) Microsoft.AspNet.WebApi.Client, Microsoft.AspNet.WebApi.Core and Newtonsoft.json
same for the above answers in my case also it is working good after updating or reinstalling packages
Microsoft.AspNet.WebApi.Client
Microsoft.AspNet.WebApi.Core