How to resolve compile errors after adding a WCF net tcp service reference in .Net Core Console App targeting .Net 5 - wcf

After I was able to add a WCF net tcp service reference to my .Net Core Console App targeting .Net 5, under the Dependencies -> Assemblies, System.ServiceModel is listed but has a yellow triangle.
When I checked the Microsoft Docs on this, there was mention it would add needed Nuget packages but non are listed for the project.
Please advise and thanks for your help,
Bob

Find Manage NuGet Packages in the project
Click Browse, search for System.servicemodel in the search box and install the Nuget package for the project.

Related

Access wcf from netcoreapp2.0

I have a asp dotnet core 2.0 project that needs to talk to a downstream WCF service
The proj file is targeting netcoreapp2.0
I have added nuget packages for System.ServiceModel.Primitives and have almost everything I need apart from something in the System.ServiceModel.Configuration namespace which doesnt appear to be available on Nuget
In the past, I have successfully talked to the WCF service in a netcore1.1 project (by making it target net461)
However, this doesnt appear to be an option if you want to take advantage of netCore2.0 functionality. If you target net461 then you cant access netcore2.0 features
Should this be possible?
Am I doing something wrong?
Can you target net461 and also use netcore2.0 features?
or is there a way I can target netcoreapp2.0 and still access System.ServiceModel.Configuration?
Or do I need to target netcoreapp2.0 and do something else that allows me to access System.ServiceModel.Configuration?
thanks
If you use at least VS 2017 version 15.5, you can add the WCF service as a connected service. The wizard will add the required packages and generate the client code. (in previous VS 2017 versions, you'd need a preview extension).
You can access this wizard from the "Add Connected Service" context menu item:

Xamarin Forms how to consume a wcf service

I've created a Xamarin project which added the following projects to the solution:
Xamarin.UI(Portable)
Xamarin.UI.Droid
Xamarin.UI.iOS
Xamarin.UI.UWP
Xamarin.UI.Windows (Windows 8.1)
Xamarin.UI.WindowsPhone (Windows Phone 8.1)
I am having problems creating a client which can consume my WCF service.
1) Firstly the current Xamarin project template doesn't reference System.ServiceModel assembly in the PCL therefore I cannot right click the PCL and Add Service Reference to my project. When I manually add a reference to System.ServiceModel from this location - C:\Program Files\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5 the menu item for create service reference pops up. When I click Go in the Add Service Reference dialog I get the following error:
"This service cannot be consumed by the current project. Please check if the project target framework supports this service type."
The PCL targets are as follows:
.NET Framework 4.5
ASP.NET Core 1.0
Windows 8
Windows Phone 8.1
Xamarin.Android
Xamarin.iOS
Xamarin.iOS
I don't know how to get this working ?
2) Secondly the work around I use is to create the client with SlSvcUtil.exe
Add the generated code to my PCL along with a reference to System.ServiceModel and everything builds ok. The problem is that when I run the code it flags up type reference errors ! Should I be manually adding the reference to System.ServiceModel anyway? What am I doing wrong in this scenario? Am I missing some steps?
I've checked the Xamarin docs but it seems that I can't find detailed instructions on this.
Please help me out ! Thanks:)
PCL and WCF should be supported. Alternatively, you could get this to work manually with HttpClient, etc. But maybe if you can use the shared project instead of PCL, that would be easier. Otherwise you'd have to also use DependencyService, create interfaces, etc. for each platform.

Microsoft.Http.dll does not exist

I need to use the REST feature, HttpMultipartMimeForm, which I believe belongs to Microsoft.Http.dll. But in my .Net 4.0 project I couldn't find it anywhere. I do have my project's Target framework configured as .Net Framework 4, not ..Client Profile, and as an evidence, I do have the System.ServiceModel.Web assembly in the available .net reference list. But I still don't have the Microsoft.Http.dll and therefore, don't have the class I need. I think I may be able to get the dll if I download and install WCF REST Starter Kit but why do I have to do that? .Net 4 is supposed to have it as part of standard, isn't it?
It's now called MultipartFormDataContent and it is in System.Net.Http. You can get the nuget from here http://nuget.org/packages/Microsoft.Net.Http/2.0.20710.0

Why is EntityFramework Namespace undefined even after installing EntityFramework with Package Manager console?

All:
We started off our project using ASP.NET Web Forms.
Our ASP.NET C# web application is used in the following environment
.NET Framework 4
ASP.NET Web Forms.
IIS 7
Windows 2008
Visual Studio 2010
.NET IDE
C#
HTTPS ( SSL )
We wanted to integrate Microsoft Entity Framework Version 5.
Therefore, from the Package Manager console in Visual Studio 2010, I ran the following command.
PM> Install-Package EntityFramework -Version 5.0
You are downloading EntityFramework from Microsoft, the license agreement to which is available at http://go.microsoft.com/fwlink/?LinkId=253898&clcid=0x409. Check the package for additional dependencies, which may come with their own license agreement(s). Your use of the package and dependencies constitutes your acceptance of their license agreements. If you do not accept the license agreement(s), then delete the relevant components from your device.
Successfully installed 'EntityFramework 5.0.0'.
Successfully added 'EntityFramework 5.0.0' to PivotServer.
Type 'get-help EntityFramework' to see all available Entity Framework commands.
As you can see above, it installed EntityFramework 5.0.0 properly.
Also, in my ASP.NET Web application, the installation automatically added EntityFramework dll to the References.
However, if I write the following
"using EntityFramework"
into one of my C# cs files, then it states that the EntityFramework is undefined.
I also Unstall the EntityFramework package, and then reinstall it but it still failed to recogonize the EntityFramework.
Please suggest what steps I have to take in order for EntityFramework namespace to be defined in my ASP.NET web project.
There is no EntityFramework namespace. Use Object Browser to see what namespaces you should use.

Building C++ projects that targets framework 3.5 but produces assemblies targeting framework 4.0

Background
We have a C++ solution that has been moved from VS2005 to VS2010 where the project files were targeting the .net framework 3.5 but since moving over to VS2010, all of the project files were showing that they were targeting the.net framework 4.0. I have since changed the .vcxproj files manually so that they are targeting the .net framework 3.5, using the method described in the Community Content on this link
The Problem
When I build these project files, manually or via an automated build, the output assemblies are still targeting the .net framework 4.0. I can tell this by using various methods described here. I also know that this is the case as I build and run the installer for this application. Once the application has been installed (which then shows as a service), I try to start the service on the target machine. This service will not start on a machine without the .net framework 4.0 installed. If 4.0 is then installed, the service will start, so this is another test that I can run that shows me that the application has a dependency on .net framework 4.0 which it should not.
The Aim
Ideally, I need to build this application so that the outputs are targeting the .net framework 3.5 instead of 4.0 so that it will actually run as it is supposed to! I have tried to use the 3.5 version of MSBuild as described in one of the answers given for this question here but got the same error that is described underneath that post.
Can anyone help with this? It's proving to be a right pain and I've been banging my head against the wall for over a week trying to get this sorted!
Thanks again in advance
Make sure you follow all the instructions as provided in the first link you posted.
For example,
Make sure you have Visual Studio 2008 installed on the build server.
Make sure you also change each project's "Platform Toolset" to v90.
Verify the project's framework version: "In Solution Explorer, right-click your project and then click Properties. In the Property Pages window, in the left pane, expand Common Properties and then select Framework and References. Verify that the new Framework version appears at the top of the right pane."