Im trying to migrate a Silverlight application to OpenSilver.
The application uses WCF service references that are included in the project.
I followed the OpenSilver example on migrating from Silverlight to OpenSilver
https://doc.opensilver.net/documentation/migrate-from-silverlight/example.html
After wrapping the application with the OpenSilver files I get an error that my services namespace could not be found, then when trying to add that missing service reference to the project I get "The target framework 'netcoreapp2.0' is out of support"
Is there a step I am missing in setting this up?
If you get the error because you copy-pasted the server references as well
If you double click that error it should bring you to the Reference.svcmap file of your WCF service reference. Find the Reference.cs file in Solution Explorer next to Reference.svcmap.
Open it and you will see the same error multiple times in the code:
"The type name 'IHttpCookieContainerManager' could not be found in the namespace 'System.ServiceModel.Channels'. This type has been forwarded to assembly 'System.ServiceModel.Http, Version=4.6.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' Consider adding a reference to that assembly."
Solution: add the following nuget package: System.ServiceModel.Http
If you try to add a new service reference then follow this workaround: https://github.com/dotnet/wcf/issues/4766#issuecomment-1007859628
I hope that helps.
Related
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.
I'm developping in Xamarin PCL a project cross-platform I'm testing on IOS and android with Visual studio 2015 V4.6. I need to include System.ServiceModel In my portable Class to consume WCF Services. I can't Include it with Nuget Packets.
Could not install package 'System.ServiceModel.Primitives 4.3.0'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile259', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
I tried to include directly Right clic on References -> path->System.ServiceModel[4.0.0.0] and then add*
I have this error message
' Severity Code Description Project File Line Suppression State
Error Can not resolve reference: /Users/ludovic/Library/Caches/Xamarin/mtbs/builds/DemoHandyLife.iOS/725fe7b4d3cb829a82e1002d425b8f86/bin/iPhoneSimulator/Debug/System.EnterpriseServices.Wrapper.dll DemoHandyLife.iOS C:\Program Files\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets 696'
If I add System.ServiceModel[5.0.0.0] I have these Error Message
Error CS0012 The type 'CookieContainer' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Net, Version=5.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.
Error CS0012 The type 'CookieContainer' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Net, Version=5.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.
I tried to add the system.Net Version=5.0.5.0 automatically but nothing happen.
Can someone Help me? Thanks in advance
Tell me if you need more details.
Thanks in advance for your help.
Hello you can't directly add your WCf service to your Portable class library, I suggest to convert your wcf Service in a wcf rest Service. I let you watch the tutorial
or you can follow this tutorial if you absolutely want wsdl service. you can add it directly in your pcl class with the last xamarin version
https://developer.xamarin.com/guides/cross-platform/application_fundamentals/web_services/walkthrough_working_with_WCF/
I recently took a legacy WCF project with Entity Framework 4 and upgraded it to EF6 and .NET 4.0. I took the legacy Silverlight client project and upgraded as well. Problems started to arise when I added a new service reference to the upgraded WCF service. The code generated in the service reference has conflicts and will not compile.
My initial problem is that both Microsoft.Data.Services.Client and System.Data.Services.Client are part of the references…
CS0433 The type 'EntitySetAttribute' exists in both
'Microsoft.Data.Services.Client, Version=5.6.4.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35' and 'System.Data.Services.Client,
Version=5.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
This surprises me even more when I look at the generated code, References.cs, that fails. The usage is fully qualified.
[global::System.Data.Services.Common.EntitySetAttribute("myTable")]. Apparently both assemblies use the exact same namespace.
If I remove Microsoft.Data.Services.Client I get:
Error CS1061 'myEntities4' does not contain a definition for
'DefaultResolveType' and no extension method 'DefaultResolveType'
accepting a first argument of type 'myEntities' could be found (are
you missing a using directive or an assembly reference?)
If I remove System.Data.Services.Client I get:
Could not load file or assembly 'System.Data.Services.Client,
Version=5.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or
one of its dependencies. The system cannot find the file specified.
This error is found in the XAML of a UserControl that uses a RadDataServiceDataSource.DataServiceContext.
I have spent quite a few hours trying several different paths including:
Getting older versions of Microsoft.Data.Services.Client from NuGet.
Using only one of the references, as mentioned above.
Changing the references in the WCF service before adding the Service Reference in the client.
Attempting advanced options when adding the Service Reference
Reuse all type from assemblies.
Reuse types in specified referenced assmeblies.
I have read the following posts, but they did not help:
Microsoft.Data.Services.Client.dll vs System.Data.Services.Client.dll
WCF error: Need to exclude all but one of the following types. Only matching types can be valid references
Project does not build after updating a service reference
I'm now considering building a new WCF and Web project to work around these issues. This should be an lengthy undertaking as well, and hopefully not a red herring.
Is this an artifact of upgrading from older versions of Silverlight, WCF, Entity Framework, or .NET in general? Please help me if you know what this is, or you have seen this before. A complete rewrite of the project to another platform is not an option unfortunately.
you can use this code :
EFContext.Configuration.ProxyCreationEnabled = false;
EFContext.Configuration.LazyLoading = false;
I have included an external reference of Moneris library eSELECTplus_dotNet_API.dll to my ASP.NET 5 RC1 project. It wrapped it alright and I can build project and run it using Kestrel. But when I publish it from VS or command line I got following error:
The package ID 'eSELECTplus_dotNet_API' contains invalid characters. Examples of valid package IDs include 'MyPackage' and 'MyPackage.Sample'.
I tried to rename library to a better name to fit nuget specs and it worked so I can publish it. But now when I run my project I got runtime error saying following:
System.IO.FileNotFoundException : Could not load file or assembly 'eSELECTplus_dotNet_API, Version=2.5.3.0, Culture=neutral, PublicKeyToken=8cb9cd598f87e276' or one of its dependencies. The system cannot find the file specified.
Please advice.
Suddenly I got the following error when publishing to Azure Mobile Services.
"Error Found conflicts between different versions of the same dependent assembly 'System.Web.Http.Cors': 5.1.0.0, 5.2.2.0. Please change your project to use only one version. App.Hosting 2014-09-20 23:40:26"
I use Microsoft.AspNet.WebApi.Cors and WindowsAzure.MobileServices.Backend (1.0.348).
I have tried going through all references and I cant find any pointing at 5.2.2.0.
I have also tried upgrading to 5.2.2.0 however when doing so I get:
"Error Boot strapping failed: executing 'WebApiConfig.Register' caused an exception: 'Could not load file or assembly 'System.Web.Http.Cors, Version=5.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.'. App.Hosting 2014-09-20 23:06:20"
I can not understand why I get this error and it seem to have start to occur with no apparent reason.
Any pointer is appreciated.
We are in the process of updating to the newly released ASP.NET Web API 5.2 and it looks like we missed an assembly redirect for the CORS assembly.
In a couple of days you will be able to use the full ASP.NET Web API 5.2 but the upgrade has to complete first. To fix your problem now, you should be able to just remove your own CORS assembly (assuming you are only setting the origins) and then set them using the MS_CrossDomainOrigins app setting in your local web.config as described in this blog [1], for example:
<add key="MS_CrossDomainOrigins" value="http://testhost, http://sample" />
Sorry for the inconvenience!
Henrik
[1] http://azure.microsoft.com/blog/2014/07/28/azure-mobile-services-net-updates/