WCF Web Service / Visual Studio Community 2022 / Compiler Error CS0120 - c#

I want to access a web page in a Windows Forms app via SOAP.
Unfortunately, the compiler spits out many errors after I added the WCF Web Service to the project. What am I doing wrong here? The possible options don't tell me anything. The examples I found on the Internet could not help me with the errors.
Visual Studio Community 2022
WCF Web Service
URI: https://www.onlinembe.de/wsdl/OnlineMbeSOAP.wsdl
[ ] Always generate message contracts
[X] Reuse types in referece assemblies
[X] Reuse types in all referenced assemblies
Access level for generated classes:
[X] Public
Compiler Error CS0120
An object reference is required for the non-static field, method or property "ShipmentRequestType.System".

In 'Reference.cs' add 'using System.Xml.Schema;'
and replace
'Form=System.Xml.Schema.XmlSchemaForm.Unqualified'
with
Form='XmlSchemaForm.Unqualified'.

Related

Azure Functions: Adding Neo4j Driver dependency to C# HTTP Trigger throws Error

Im creating a Azure function which should connect to a neo4j database after receiving a https request. I used the Visual Studio 2015 function preview to set up my project and to create a C# HTTP trigger function.
I then added a Neo4j dependency to my project.json
"dependencies": {
"Neo4j.Driver": "1.2.0"
}
After a NuGet rebuild i get multiple error like the following:
run.csx(8,19): error CS1929: 'HttpRequestMessage' does not contain a definition for 'GetQueryNameValuePairs' and the best extension method overload 'HttpRequest MessageExtensions.GetQueryNameValuePairs(HttpRequestMessage)' requires a receiver of type 'HttpRequestMessage'
I didn't change anything else of the default function code and after adding the dependent the Framework Versions are still the same.
Do i have to add some default dependencies so that i can still use the HTTP trigger?
Edit: i uploaded the Content of the project.lock.json files maybe this helps
Without dependency https://api.myjson.com/bins/1f5hrv
With dependency (3000 lines) https://api.myjson.com/bins/14fovv
The reference to Neo4j.Driver causes a reference to System.Net.Http to be added, using a version that leads to a type mismatch between what is referenced and the extension methods from the assemblies provided by the runtime.
Please add your own references to System.Net.Http, see this stackoverflow question: Azure Functions - System.Net.Http

Compiler error referencing Service Fabric Actor class from ASP.NET Core service

This has been bugging me all day and I have yet to figure out why this is happening.
Basic scenario
Created a new Service Fabric Application with an ASP.NET Core service and added support for returning MVC views so that it can act as the UI for my SF App.
Added an Actor service for users to the solution which created the UserActor and UserActor.Interfaces projects and ensured that the Interfaces library targets x64 as required by SF.
Defined a Task<UserProfile> GetProfileData() method on the UserActor where the UserProfile type is a concrete class defined in the Interfaces project with the [DataContract] and [DataMember] attributes so that it can be serialized (all members are primitives).
Added a project reference to the UserActor.Interfaces from the ASP.NET Core project so I could create the actor proxy and invoke the method.
Added the code in the ASP.NET Core Controller class to connect to the actor instance and invoke the GetProfileData method
At this point, I receive the following compiler error:
error CS0246: The type or namespace name 'UserProfile' could not be found (are you missing a using directive or an assembly reference?)
The relevant lines of code are as follows:
using UserActor.Interfaces;
var user = ActorProxy.Create<IUserActor>( new ActorId( model.email ), FabricAppUrl );
UserProfile profile = user.GetProfileData().Result; // compiler error here
If I hover over the UserProfile type on the last line, Visual Studio shows me it sees the type as UserActor.Interfaces.UserProfile and doesn't show any errors in the editor. It's only when I compile that this error shows up.
I didn't receive this error when trying to return a primitive type and it had no problem resolving the IUserActor interface for the Actor Proxy either.
Does this have something to do with the fact the the Actor projects are standard .NET projects and the ASP.NET Core project is compiled using dotnet build (set to .NETFramework,Version=v4.5.2; not dotnet core).
I also noticed in the build output that the ASP.NET Core project is building as 'Debug Any CPU' while all of the other projects are set to 'Debug x64'. If this were the issue I would expect to receive an error about mis-matched architecture types, but I'm not getting that either.
How can I resolve this? Should I be returning the data from the Actor in a different manner (such as json serializing it before returning it as a string primitive)?
Edit 1:
The code sample above was too simplistic. The 2 compiler errors I am seeing are around the type being passed to a helper method in the same controller as follows:
private bool TryGetUserProfile( LoginModel model, out UserProfile profile )
{
var user = ActorProxy.Create<IUserActor>(new ActorId(model.Email), FarbicAppUrl);
var profile = user.GetProfileData().Result;
return !string.IsNullOrEmpty(profile.Name);
}
OK, after starting the whole scenario out on a different machine I found what the problem is and believe it to be a Microsoft tooling issue. Here are the steps to reproduce the problem along with what needs to be done to correct it.
Create a new Service Fabric project and select ASP.NET Core as the service. If prompted, select the Web Application Template (but I think this would be an issue if you selected the Empty or Web API templates as well). If you debug this, it will work just fine (provided you have a local cluster setup).
Add a new Actor Service to the solution. This will create the UserActor and UserActor.Interfaces projects for you. If you try to compile at this point, you will receive the following error message:
C:\Program Files (x86)\MSBuild\bin\Microsoft.Common.CurrentVersion.targets(724,5): error : The OutputPath property is not set for project 'UserActor.Interfaces.csproj'. Please check to make sure that you have specified a valid combination of Configuration and Platform for this project. Configuration='Debug' Platform='AnyCPU'. This error may also appear if some other project is trying to follow a project-to-project reference to this project, this project has been unloaded or is not included in the solution, and the referencing project does not build using the same or an equivalent Configuration or Platform.
Checking the Configuration Manager shows that there is only an 'x64' target defined for the project. To get around this, use the Configuration Manager and add a new 'AnyCPU' target and copy it from the 'x64' target. Ensure that the target platform is still set to 'x64' for the interfaces project before closing the Configuration Manager since Service Fabric requires x64 assemblies.
Now when you compile, you will receive the following error message:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.Targets(262,5): error : C:\...\Web error CS0006: Metadata file 'C:\...\UserActor.Interfaces\bin\Debug\UserActor.Interfaces.dll' could not be found.
The clue here is that the web project is looking in the OutputPath location defined for the 'AnyCPU' target and not the location defined for the 'x64' target (bin\x64\Debug). If you manually edit the interfaces project file and set the OutputPath for the 'AnyCPU' target to the same path as the 'x64' target, everything will compile properly.
You can also deploy the project and everything will work as it should. I'm not sure which target file from Microsoft has the problem in it, but it could be both. I'll look into reporting this as a bug with Microsoft in the hopes of getting it resolved (still present with the latest SDK released on 2/3/2017).
The reason the UserProfile type couldn't be found for me was because I had previously built the solution with the wrong OutputPath set before I added the UserProfile class to the project so the compiled DLL that MSBuild was looking at didn't contain the type. If I had removed the bin & obj folders from the solution, it would have become obvious where the problem was right away.

SQL Server Reporting Service 2010 | Not working in Console app

I want to list all the subscriptions made in the reporting server. For this I created a sample console application and added the reference of Microsoft.ReportViewer.WebForms.dll located in the
%Program Files(x86)%\Microsoft Visual Studio
11.0\ReportViewer\Microsoft.ReportViewer.WebForms.dll
But, when I am trying to create object of ReportingService2010 using the following
ReportingService2010.ReportingService2010 r = new
ReportingService2010.ReportingService2010();
It won't allow me to create the object, and throws a compile time error
error CS0246: The type or namespace name 'ReportingService2010'
could not be found (are you missing a using directive or an assembly
reference?)
Which ddl's I am missing here please help me.
Microsoft has a ReportViewer package that needs to be deployed (link below). Adding reference to the project from your development box may not be sufficient.
http://msdn.microsoft.com/en-us/library/ms251723.aspx
I believe the ReportingService2010 is not part of the reference Microsoft.ReportViewer.WebForms.
You need to add a web refrence to your project.
Here is a great tutorial from Microsoft, it shows you how to add a web reference to the SQL Server Reporting Web Service:
http://technet.microsoft.com/en-us/library/ms169926.aspx
If you follow these steps you should be able to use ReportingService2010 like this:
ReportingService2010 rs = new ReportingService2010();

Visual Studio OData "Add Service Reference" code-gen failing

This data.gov website gives an OData data export with instructions to use the link http://data.cms.gov/OData.svc/97k6-zzx3
(After Nugeting Install-Package Microsoft.Data.Services.Client version 5.6.1) I attempt to use the full link to "Add Service Reference" to my C# project in either Visual Studio 2012 or Visual Studio 2013, I get There was an error downloading 'http://data.cms.gov/OData.svc/97k6-zzx3/_vti_bin/ListData.svc/$metadata'.
The request failed with HTTP status 404: Not Found. ...
If I truncate the URL to http://data.cms.gov/OData.svc then I get one step further, but still an error The custom tool 'DataServicesCoreClientGenerator' failed. Data service client code-generation failed: Schema specified is not valid. Errors: ... The 'Name' attribute is invalid - the value '97k6-zzx3' is invalid according to its datatype (I suppose since C# identifiers cannot begin with digits)
Is this a bug with data.cms.gov or Visual Studio (etc)? Is there a close workaround?
Thanks!
Try using https://data.cms.gov/OData.svc/$metadata. Code-generation needs metadata, the above URL will provide that.
The URL https://data.cms.gov/OData.svc is the service document, not metadata.

nettiers data class library not recognized

I needed to make a console application using nettiers class libraries. I created a new Console Application project, added references to all the libraries from NetTiers and created an app.config file with all the necessary configurations. I get intellisense and no errors and everything when I am doing the coding, but when I go to compile the application, I'm getting an error that PPGEDI.Data doesn't exist.
I only have 1 line in the program.cs Main method:
PPGEDI.Entities.VansEntity van
= DataRepository.VansEntityProvider.GetById(16);
I'm getting the following error:
Error 93
The type or namespace name 'Data'
does not exist in the namespace 'PPGEDI'
(are you missing an assembly reference?)
It's frustrating, because I know I've added the assembly reference:
I'm using Visual Studio 2010, with C# and .NET 4.0. Can anyone give me an idea as to what I need to do to get this to work.
As a note, this works if I use the same statement in a method on an ASPX page in the web application generated by nettiers.
#BrokenGlass, you were absolutely correct. I double checked and it was
set to ".NET Framework Client Profile", I changed it to .NET 4 and
it's working now, can you put that as an answer?
You are using the .NET client profile in your console app which is a "minified" version that doesn’t contain all assemblies.
The problem is that when your app adds a reference to a class library that is targeting the full framework, references to the "full" framework assembly will not resolve. This results in the rather non-forthcoming error message that you see. Switching to the the full .NET 4 as target framework will resolve the issue.
For a more in depth overview of the problem and the .NET 4 Client Profile in general also see "What’s new in .NET Framework 4 Client Profile RTM"

Categories