Using System.Web.Http on mac os x - macos

I'm new to mac but not .Net. I'm playing around with Visual Studio Code. I installed Brew and used it to get yo, grunt-cli, generator-aspnet, dnvm, and everything the tutorials say to get. I created a project scaffold with yo and the first thing I want to do is add a Controller that inherits from ApiController but I can't seem to find a way to "Add a reference" like I would in Visual Studio proper.
It looks like I should open project.json and add something like this:
"System.Web.Http": "<some version number>"
under dependencies. I don't know what version number to use, so I tried "latest" but anytime I run dnu update it says System.Web.Http can't be found.
Where can I find information about adding references to Visual Studio Code? How to reference particular DLLs (specifically System.Web.Http for me) and what versions to reference?

The answer to your question has several parts.
ApiController
First of all, ASP.NET MVC 6 unifies WebAPI and MVC 5 controllers into one. You can still use ApiController if you want to, but you will need Microsoft.AspNet.Mvc.WebApiCompatShim.
There is no System.Web.Net
Second, Matt DeKrey is correct. System.Web.Http is not a .NET core library. Depending on what you are trying to do, you may be looking for System.Web.Http.Common.
Finding package version
When using VS Code, you should be seeing autocomplete that will recommend version numbers for you. In this case you could use:
"System.Web.Http.Common": "4.0.20216.16343"

Related

How to use SignalR in aspnetcore 2.0, with c# and html/js for front end

Am trying to install SIGNALR to my asp.net project, but when adding the Nugets, it keeps pushing an error that the "Package xxx was restored using .NETFramework, Version=v4.6.1 instead of the project framework .NETCoreApp, Version=v2.0". I get this error on several Nugets. I tried to re-install all Nuget one by one but same result when I arrive at some particular one like SIGNALR.
I believe I might have something wrong in the setup, but as am new to asp.net, would love a pointer. Read the literature but could not find the answer to this issue.
It also looks like SignalR might only be available for netcore 2.1 later this year but am looking for a way to use it, in a simple app.
So a couple of things.
For the latest SignalR Core bits you need to be targeting netcoreapp2.1. Preview1 and later depend on that.
If you want to just experiment with SignalR targeting netcoreapp2.0 the alpha 2 bits use netcoreapp2.0. But just to be clear the alpha bits are just a public preview and should not be used for production applications.
The main thing here though is that you are using the Microsoft.AspNet.SignalR packages. Those will not work on Core.

Sitecore 8.1: Glass.Mapper & Razor

Running a new site on Sitecore 8.1 - installed and setup Glass.Mapper but I cannot use calls such as #RenderImage - it's complaining that i'm missing the reference to Glass.Mapper.Sc.Mvc, which I have already.
The following are the Nuget modules installed for Glass.Mapper:
BoC.Glass.Mapper
BoC.Glass.Mapper.Sc
BoC.Glass.Mapper.Sc.CastleWindsor
Castle Windsor
Castle.Core
Glass.Mapper.Sc
I have it installed on another instance of Sitecore (7.5) - an older version of Glass.Mapper, but I've noticed that the Nuget packages do not exist anymore.
Any ideas?
Thanks!
Dan
BoC.Glass.Mapper is a fork of Glass Mapper, and I believe it has not been updated to V4. Remove it (and any configs that it added or deployed) and start again I say. Just add the Glass.Mapper.Sc nuget package will add in the correct dependencies and is compatible with Sitecore 8.1.
Just to be doubly sure, this is the correct version: https://www.nuget.org/packages/Glass.Mapper.Sc/
Make sure you have Sitecore.Kernel and System.Web.Mvc referenced in your project since there is a post-install step in the nuget package that adds the correct versions of Glass dlls to your project.
To make things simpler V4 uses a Powershell script to decided which
references to add to your project, it checks both the Sitecore.Kernel
version and the System.Web.Mvc version and then installs the
appropriate Glass.Mapper.Sc and Glass.Mapper.Sc.Mvc assembly.
With regards to #RenderImage, either inherit your view from GlassView<> or better to use the extension methods, e.g. #Html.Glass().RenderImage().
More info here: http://glass.lu/Blog/GlassV4

Where is IApplicationBuilder.UseJwtBearerAuthentication extension in ASP.net 5?

I've seen examples that that indicate IApplicationBuilder has an extension method .UseJwtBearerAuthentication(Action<?> options).
This SO question and AspNet.Security.OpenIdConnect.Server
sample server startup file seem to say that there is such an extension. On the OpenIdConnect, I looked at the extensions folder and I don't see an extension named UseJwtBearerAuthentication. Even this blog says that it's supposed to be included with ASP.net 5. I also tried adding Microsoft.AspNet.Security.OAuthBearer, 1.0.0-beta3 to my project.json and reference it in Startup.cs. No help.
The only thing I have different is that I'm using -beta7, but I don't think that should matter.
It depends on your runtime version. In beta7 the package is called Microsoft.AspNet.Authentication.OAuthBearer, while in beta 8 the package is renamed to Microsoft.AspNet.Authentication.JwtBearer.
Since you are using beta7, add this to your project.json:
"Microsoft.AspNet.Authentication.OAuthBearer": "1.0.0-beta7"
Pro-tip: never mix beta versions like beta3 security packages and beta7 MVC packages.
In RC2, there are
Microsoft.AspNetCore.Authentication.JwtBearer
Microsoft.AspNetCore.Authentication.OAuth

Where can I get the latest Microsoft.Exchange.WebServices.DLL?

I'm trying to use the latest Exchange Web Services DLL, however when I search my hard drive I see many versions of Microsoft.Exchange.WebServices.DLL, the most recent being version 14.0.650.7 with a date of 1/24/12.
I want to rebuild my machine but can't find an official place to get this DLL. I attempted to download the latest SDK I don't see any DLL to use, nor is there any CHM for me to use.
Where can I get the latest version of Microsoft.Exchange.WebServices.DLL?
Current version of the EWS Managed API is 1.2. It seems that Microsoft sometimes forgets to update links to the newest download which makes it hard to find out what the newest version is but I usually go to www.microsoft.com/downloads and search for "Exchange Web Services Managed API" whenever I need a fresh download.
UPDATE:
EWS is on NuGet:
http://www.nuget.org/packages?q=EWS
This is an old question, and the two answers by the OP and #JakobChristensen do answer the question. I'll just mention that I'm finding the situation fairly confusing.
I recently (manually, not via NuGet) downloaded the current NuGet version, which they currently call "2.2.0".
https://www.nuget.org/packages/Microsoft.Exchange.WebServices/
But the internal file/product version on the .dll is 15.00.0913.015.
According to this page
https://msdn.microsoft.com/en-us/library/office/dn528373(v=exchg.150).aspx
the file should be placed here:
C:\Program Files\Microsoft\Exchange\Web Services\2.0\
So that's where I placed it. Later, when playing around with a Microsoft sample program I noted that it did indeed reference the file at that location.
But another Microsoft sample program referenced the file in the GAC!
C:\WINDOWS\assembly\GAC_MSIL\Microsoft.Exchange.WebServices\15.0.0.0__31bf3856ad364e35\Microsoft.Exchange.WebServices.dll
This version had file/product version 15.00.0847.030.
I'm not sure how that file got there, probably part of a Visual Studio installation.
There's also something called EWSCore, which is apparently a forked version of the official EWS with some bug fixes.
https://www.nuget.org/packages/EWSCore/
My current decision is that I'll consider the official NuGet version to be the version I'll standardize on, and manually download it to my development PC and my build PC and place it here:
C:\Program Files\Microsoft\Exchange\Web Services\2.0\
Options
If you use .net framework, there is a nuget package "Microsoft.Exchange.WebServices 2.2.0" here https://www.nuget.org/packages/Microsoft.Exchange.WebServices
If you use .netstandard/.net5+, you need to go the Github open source project "OfficeDev /
ews-managed-api" here https://github.com/OfficeDev/ews-managed-api , and there you download the code, and compile it. However, this project is targeting .net3.5. So, you need to convert/upgrade it to .netstandard/.net5+ manually and compile it for your self.
!! Update !!: I took the version as of date of this post from GitHub. Replaced Old Style project with SDK project. Target framework set to netstandard2.0. Added packages System.DirectoryServicesandSystem.Security.Cryptography.Xml. In files, I had to remove few namespaces that not compatible, but were not used. Removed AsImageinPhoto, this is public image retrieving method, not needed - it only converts byte array. And fixed loading issue with Assembly.GetExecutingAssembly().GetTypes();`
Type[] types;
try
{
types = Assembly.GetExecutingAssembly().GetTypes();
}
catch (ReflectionTypeLoadException ex)
{
types = ex.Types.Where(t => t != null).ToArray();
}
I also deleted or excluded from project bunch of files related to documentation, fxcop, and assembly info.
And then it worked for sending emails with different API versions. Reading emails is not tested yet.
There is a third option. Nuget has a package "Microsoft.Exchange.WebServices.NETStandard 2.0.0-beta3" But this is not an official Microsoft code. https://www.nuget.org/packages/Microsoft.Exchange.WebServices.NETStandard/2.0.0-beta3
!! Update !!: Got this version and compared to the original code in option #2. This code has more changes than necessary to convert to .netstandard. It has some async stuff added.

strange problem with referenced log4net assembly

I'm not sure if this problem is connected specifically with log4net or this is some problem with VS.
Everytime I'm trying, I have the same result. But let's start from the beginning.
I'm creating a simply console application (.net 4) and using nuget to install the log4net library.
Now, when I want to add some code from it, intellisense works ok:
But when I try to compile it, I have an error
This is the only one assembly I found to this moment, I have this problem with. I have absolutly no idea what (and why) is going on. I have checked with two other solutions and problem is the same. I have not checked manually downloaded version yet.
Most likely there is an underlying dependency that is missing. One very common reason is the project is using the Client Profile instead of the full .NET 4.0. (Not sure about log4Net, but I run into this a lot when including third party libraries, esp. those with ties to the web). If I am correct, simply going into properties and changing the framework version to full .NET 4.0 will solve the issue.

Resources