I am currently trying to connect my ASP-NET Core 2 application to Magento's API (WSDL v2), but keep receiving the following errors:
*Doesn't matter which method I call, even the new PortTypeClient().loginAsync(username, password); throws that, with this random endpoint name salesOrderShipmentAddComment.
InvalidOperationException: The operation
'salesOrderShipmentAddComment' could not be loaded because it
specifies \"rpc-style\" in \"literal\" mode, but uses message contract
types or the System.ServiceModel.Channels.Message. This combination is
disallowed -- specify a different value for style or use parameters
other than message contract types or
System.ServiceModel.Channels.Message.
However, using SoapUI, postman or importing with framework 4.6, it works perfectly.
Using the Magento v1 API it works too, but I don't want to use this version.
During the import in asp-net core, I also recieve those warnings (importing v1 doesn't shows any warning):
I'm almost creating a new 4.6 application, hosting it separately to work as a bridge between my application and Magento, even if it hurts my performance and architeture.
This is how I'm doing the import:
*Obs: In Data Type Options, I also tried checking different options, and selecting other data types.
Anything would help...
Thanks in advance
I had the same problem. Make sure you update your Nuget Packages to 4.5.3. After, works correctly for me.
Indeed updating the following packages to version 4.5.3 seems to resolve the issue:
System.ServiceModel.Duplex
System.ServiceModel.Http
System.ServiceModel.NetTcp
System.ServiceModel.Security
Seems like 4.4.4 version of those packages are installed by default, while adding WCF service reference via VS 2017 15.9.4 UI
Just update System.ServiceModel.Http to 4.5.3
According to
https://ozguradem.net/english/coding/2018/11/06/soap-services-with-dotnet-core/
Open .csproj file and edit following packages minimum version like these
<ItemGroup>
<PackageReference Include="System.ServiceModel.Duplex" Version="4.5.*" />
<PackageReference Include="System.ServiceModel.Http" Version="4.5.*" />
<PackageReference Include="System.ServiceModel.NetTcp" Version="4.5.*" />
<PackageReference Include="System.ServiceModel.Security" Version="4.5.*" />
</ItemGroup>
Related
Where is CircuitHandler in Blazor .NET 6?
As I am upgrading packages to .NET 6, I noticed in nuget package manager that Microsoft.AspNetCore.Components.Server package was marked obsolete and so assuming CircuitHandler was moved to another package and that one is no longer needed (As they have done in the past with IAsyncEnumerable and Span<T>), I removed the package. Then I realized that package has completely been removed from nuget browser altogether, and there is no word anywhere I can find on any alternative for .NET 6. MSDN even has Blazor .NET 6 articles talking as if CircuitHandler is easily found in Microsoft.AspNetCore.Components.Server namespace, but no mention of what package or how to get access to that namespace! Example here
I figured this out, as I noticed the type exists in my BlazorApp project, but not my library project. It was a matter of figuring out what the differences are, and it turns out that you need to put <Project Sdk="Microsoft.NET.Sdk.Web"> in the project file instead of <Project Sdk="Microsoft.NET.Sdk">. So just adding the .Web part fixed the issue!
Note: Now my library won't build because it says I need a static Main method entry point. So it seems they aren't allowing CircuitHandlers in class libraries anymore, they must all reside in the Web App itself. Total bummer!
The real solution is to add the following to your project file. What a runaround this was for me to figure out! And I could not find this documented anywhere!
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
I am following a tutorial for implementing Azure Notification Hubs in my backend application (https://learn.microsoft.com/en-us/azure/developer/mobile-apps/notification-hubs-backend-service-xamarin-forms).
The tutorial focuses on using a API build in .NET Core, though my existing API is build in .NET 4.7.2 and for now it is to much of a hassle to rewrite the entire API.
Although I got most of it working in .NET 4.7.2, I am stuck on the following.
In the tutorial the following is being set for Dependency Injection:
services.AddOptions<NotificationHubOptions>()
.Configure(Configuration.GetSection("NotificationHub").Bind)
.ValidateDataAnnotations();
I have rewritten this to:
services.AddOptions<NotificationHubOptions()
.Configure(ConfigurationManager.GetSection("NotificationHub").Bind)
.ValidateDataAnnotations();
Sadly, I get a error on the Bind property that apparently does not exist:
'object' does not contain a definition for 'Bind' and no accessible extension method 'Bind' accepting a first argument of type 'object' could be found.
Any clue how I can get this to work (or with the same functionality) in .NET 4.7.2?
The NotificationHub config setting is a setting stored in a secrets file.
You need to install the Microsoft.Extensions.Configuration.Binder package.
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="5.0.0" />
The ConfigurationBinder.Bind method is part of that package.
I'm trying to run an HTTP triggered v2 function in Visual Studio 2019.
It's supposed to write its output into an Azure Storage Table called "history".
I've decorated one my functions with
[return: Table("history")]
and I make it return a subclass of TableEntity.
This results in an exception about it being "unable to bind Table to CloudTable". The reason for the exception is a check within the CloudStorageAccount client's code:
bool bindsToEntireTable = tableAttribute.RowKey == null;
if (bindsToEntireTable)
{
// This should have been caught by the other rule-based binders.
// We never expect this to get thrown.
throw new InvalidOperationException("Can't bind Table to type '" + parameter.ParameterType + "'.");
}
Another function binds to a CloudTable as an input parameter and suffers from the same exception.
Although binding to CloudTable should work (https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-table#input---c-example---cloudtable) it apparently does not.
Is this a bug in the client SDKs for Azure Storage or am I doing something wrong? I'm referencing these Nuget packages:
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.0.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.DurableTask" Version="1.8.3" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="3.0.6" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="2.2.0" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.29" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
The problem is a version mismatch of two Nuget packages. When creating a new solution I was unable to replicate the issue and binding to CloudTable worked just fine. Comparing to my solution revealed that my function project referenced another project which had a dependency on
WindowsAzure.Storage (9.3.3)
because I needed the TableEntity type in there.
And now it's getting tricky. The functions project has a reference to
Microsoft.Azure.WebJobs.Extensions.Storage (3.0.6)
and that one has a dependency on
WindowsAzure.Storage (9.3.1)
The version difference of 9.3.3 and 9.3.1 leads to the binding problems.
The solution is to either downgrade to 9.3.1 in the referenced project
or
alternatively (and probably recommended): remove WindowsAzure.Storage from the referenced project and replace it with Microsoft.Azure.Cosmos.Table which also contains TableEntity. Important do NOT confuse this with Microsoft.Azure.CosmosDB.Table (notice the "DB") which is being deprecated. Unfortunately, the comments for WindowsAzure.Storage (9.3.3) tell us to change to exactly that incorrect package.
Concusion: it's a hot mess :-)
I had similar problems, I got this when I tried to start my Azure Function V3:
Error indexing method 'Function' Cannot bind parameter 'Table' to type CloudTable. Make sure the parameter Type is supported by the binding. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).
As stated, I saw in my project that the WindowsAzure.Storage had a warning sign and stated that it is deprecated.
The fix for me to get my project listening on Table Storage events was to change the using. Apparently I already got a reference to Cosmos in my project using the Microsoft.Azure.WebJobs.Extensions.Storage
Fixing the issue for me by removing the using: using Microsoft.WindowsAzure.Storage.Table; and just replace it with using Microsoft.Azure.Cosmos.Table;
But be aware if you are using the ObjectFlattenerRecomposer.Core it is still using Microsoft.WindowsAzure.Storage.Table and will not work with Microsoft.Azure.Cosmos.Table yet. I have contacted the developer regarding this.
(updated - see below)
I have an ASP.NET MVC5 application (multiple Assemblies) all addressing the .NET Full Framework 4.7.1
I recently added a (private) NuGet package that we built using .NET Standard 2. From Quickstart: Create and publish a package using Visual Studio (.NET Framework):
Unless you have a reason to choose otherwise, .NET Standard is the preferred target for NuGet packages, as it provides compatibility with the widest range of consuming projects.
Since then, things just haven't been the same.....there are a list of errors that I mention below, but I suspect they're all symptoms of the same issue (discussed at the end).
Please note: I'm using Visual Studio 15.7.1, and all NuGet packages use the package.config manage format rather than PackageReference.
First problem
Method not found:
'System.Collections.ObjectModel.Collection`1
System.Web.Http.HttpConfiguration.get_MessageHandlers()'
My guess here is that there's a .NET Standard version of System.Web.Http that doesn't have this method, and my application has chosen to address this rather than the 4.7.1 framework.
I partially fixed this by adding the following to my web.config file:
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="B03F5F7F11D50A3A" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
</dependentAssembly>
I say "partially" fixed it, this fixes the problem when run in my DEV environment (with Visual Studio) but when published to our QA environment, the issue remains. Any ideas on how to fix this?
Note: The MVC project's reference to System.Net.Http exists in the following path (it is NOT a NuGet package):
C:\Program Files (x86)\Microsoft Visual
Studio\2017\Professional\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net471\lib\System.Net.Http.dll
Second problem
Two of the Assemblies are involved with pulling data from various web-sources (WCF, web-api, web-service). When compiling these in RELEASE mode (where I have code analysis etc turned on) I get the following error reported:
An attempt was made to load an assembly with an incorrect format:
C:\Program Files (x86)\Reference
Assemblies\Microsoft\Framework.NETFramework\v4.7.1\Facades\System.IO.Compression.ZipFile.dll. {Name
of the assembly} {Path to the assembly}\SGEN
I found one post had the following suggestion:
Another suggestion I saw (which didn’t help me at all), was to disable
the project from creating a serialization assembly. Follow these
steps to do that (it may or may not help, but it’s worth a try):
In Solution Explorer, right click on the project that has the error and go to Properties.
In the Build tab, scroll to the very bottom and change Generate
Serialization Assembly to Off
I tried this and yes, it worked for me. However, these are the two projects that are serializing objects to send to these various web sources, so the last thing I want to be doing is un-optimizing serialization within my application...
Any suggestions on what might be wrong, or how I should best proceed?
UPDATE 14-May-2018
I found a great article from Scot Hanselman regarding NuGet packages which states:
As Oren wisely says:
"Using .NET Standard requires you to use PackageReference to eliminate
the pain of “lots of packages” as well as properly handle transitive
dependencies. While you may be able to use .NET Standard without
PackageReference, I wouldn’t recommend it."
However, there's a catch.... In Visual Studio, there is now an easy way to migrate an assembly from the older package.config to PackageReference as detailed in this link, but that article clearly states:
Note that the migrator does not presently support C++, JavaScript, and ASP.NET (.NET Framework) projects.
And when attempting this, the migration tool duly notified me that for the NuGet packages Microsoft.AspNet.Mvc and Microsoft.AspNet.WebPages:
"content" assets are not available when the package is installed after the migration
UPDATE 23-May-2018 I found several other people are experiencing a similar issue. From GitHub: .NET 4.6.1/.NET Standard 2.0 build with SGen fails #1630. Their "solution" was again to disable the serialization (see above) which would ruin performance on my application.
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
Conclusion?
So, am I right to conclude that to consume a .NET Standard 2.x NuGet package in a .NET FullFramework application, I need to use PackageReference rather than package.config and this is currently not possible with AspNet.MVC applications? In other words, it's not currently possible.
I've got this problem with .Net Framework 4.8 application and System.Buffers assembly incorrect format
The MarkKharitonov advice has solved the error. With Directory.Build.targets file I can built a project without any problem.
<Project>
<ItemGroup>
<ReflectionOnlyAssemblyNames Include="Microsoft.Bcl.AsyncInterfaces"/>
<ReflectionOnlyAssemblyNames Include="System.Buffers"/>
<ReflectionOnlyAssemblyNames Include="System.Numerics.Vectors"/>
<ReflectionOnlyAssemblyNames Include="System.Runtime.CompilerServices.Unsafe"/>
</ItemGroup>
<Target Name="RemoveDesignTimeFacadesBeforeSGen" BeforeTargets="GenerateSerializationAssemblies">
<ItemGroup>
<_ReflectionOnlyAssembly_Names Include="#(_ReferencePath_Names)"
Condition="'#(ReflectionOnlyAssemblyNames)' == '#(_ReferencePath_Names)' And '%(Identity)' != ''"/>
</ItemGroup>
<ItemGroup>
<ReferencePath Remove="#(_DesignTimeFacadeAssemblies_Names->'%(OriginalIdentity)')" />
<ReferencePath Remove="#(_ReflectionOnlyAssembly_Names->'%(OriginalIdentity)')" />
</ItemGroup>
<Message Importance="normal" Text="Removing DesignTimeFacades from ReferencePath before running SGen." />
</Target>
<Target Name="ReAddDesignTimeFacadesBeforeSGen" AfterTargets="GenerateSerializationAssemblies">
<ItemGroup>
<ReferencePath Include="#(_DesignTimeFacadeAssemblies_Names->'%(OriginalIdentity)')" />
<ReferencePath Include="#(_ReflectionOnlyAssembly_Names->'%(OriginalIdentity)')" />
</ItemGroup>
<Message Importance="normal" Text="Adding back DesignTimeFacades from ReferencePath now that SGen has run." />
</Target>
</Project>
I'm using Code on OSX together with the .NET Core. While trying to create an ArrayList I'm getting an error that the namespace cannot be found.
The System.Collections is used already. While examining what is suggested from System.Collections I see that not all of the methods are listed as in the documentation.
What could be the problem? I installed the latest .NET Core from MS site.
You cannot use the type because it is defined in a separate NuGet package,
http://www.nuget.org/packages/System.Collections.NonGeneric/
Note that only a few platforms are supported by this package, so for some monikers, you cannot reference it.
The recommended approach is to switch to the generic version of the collection types.
Looks like System.Collections.NonGeneric is not supported in Mac. It didn't work for me even though I had that package installed. Looks like it's deprecated and also Microsoft suggests that to use Generic lists instead.
Open you .csproj and add the following under
<ItemGroup>
<PackageReference Include="System.Collections.NonGeneric" Version="4.3.0">
</PackageReference>
</ItemGroup>
in the terminal or command prompt, make sure you are on the same working directory as your project and run
# dotnet restore
You can now use it in your project