I've only been able to find a couple of people online mentioning this, and it seems to be as simple for them as adding the service reference.
However, when I attempt to add a service reference for my WCF service (which works correctly in a regular console app, so I have ruled the WCF out as the problem) I receive a host of errors.
Warning 5 Custom tool warning: No endpoints compatible with Silverlight 3 were found. The generated client class will not be usable unless endpoint information is provided via the constructor.
Warning 6 Custom tool warning: Exception has been thrown by the target of an invocation.
Warning 2 Custom tool warning: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter
Error: Could not load type 'System.Runtime.Serialization.DataContractSet' from assembly 'System.Runtime.Serialization, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.
Warning 4 Custom tool warning: Cannot import wsdl:port
Detail: There was an error importing a wsdl:binding that the wsdl:port is dependent on.
Warning 3 Custom tool warning: Cannot import wsdl:binding
Detail: There was an error importing a wsdl:portType that the wsdl:binding is dependent on.
Error 7 Custom tool error: Failed to generate code for the service reference 'ServiceReference'. Please check other error and warning messages for details.
I find it strange that the first error mentions Silverlight 3, as I just completely uninstalled and reinstalled all of my development tools to ensure that I was using the latest version of .NET and Silverlight.
These errors look similar to the ones I see if I attempt to create a new Silverlight project and do not check the box "Enable WCF RIA services". I have not been able to find any means to enable that for WP7, if that is indeed the problem.
Any assistance from you scholarly gentlemen (and gentlewomen) would be much appreciated.
I ran into the exact same error, and changed the collection type to System.Collections.Generic.List instead of System.Collections.ObjectModel.ObservableCollections. This was odd since I did not even check the box for "Always generate message contracts".
Hope that helps.
Mmmm, I just changed the service reference config by unticking the "reuse type ...." box and then update worked and it generated the service config file. Not sure if this will help you?
Remember that Silverlight - even for Windows Phone, which uses a specialized version of Silverlight 3 - does NOT work with all WCF Service bindings/endpoints, but instead only supports a subset (which excludes WS-HTTP bindings, for example.) Your simplest bet is to create your WCF service for Silverlight applications using the "Silverlight-enabled WCF Service" template in Visual Studio (under Add/New Item/Silverlight).
This blog entry (http://blogs.msdn.com/b/silverlightws/archive/2009/03/20/what-s-new-with-web-services-in-silverlight-3-beta.aspx) from the Silverlight WCF Team Blog should shed some light on the possibilities. You may want to check out he whole blog (http://blogs.msdn.com/b/silverlightws/), as it has some interesting how-to and gotcha articles.
This problem occurred when you run the Visual Studio with Administrator Privilege. What you can do for a workaround is run the Visual Studio without Administrator Privilege, add the web service reference that will generate the proxy classes and close the solution. Open the project solution again in Visual Studio with Administrator privilege. A bug report already file in Microsoft Connect.
https://connect.microsoft.com/VisualStudio/feedback/details/624984/error-warnings-when-adding-web-reference-on-windows-phone-7-project?wa=wsignin1.0
Yes this is one strange Error. You will be able to return Strings, Integers etc but anything else like ArrayList and so forth you will get this error.
There is nothing wrong with your code, there is just a bug with VS. Microsoft have fixed it (check service packs) but if you are programming for Windows Phone 7, the bug is still there.
You have Delete the Service, Then Bin and Obj Folder. Save and close VS. Then restart the Project, Add the Service Ref (DO NOT DEBUG/RUN the app). Oh Yes DO A BACKUP FIRST. It should be ok. You may have to repeat this process everytime you Update the Service.
This should fix it, if not, you may have to open a new project or if possible recreate the Webservice.
The answer is yes, you can access WCF services from WP7, and like a previous poster noted it only supports WS-HTTP. In the case that you are trying to access a WCF Service for a Silverlight application then there are a few things that you need to do:
Update your Silvleright Toolkit to the latest. Go get it from Codeplex
Add a reference to Microsoft.ServiceModel.DomainServices.Hosting to your silverlight project.
Go to the Web.Config and add the soap endpoint:
<domainServices>
<endpoints>
<add name="Soap"
type="Microsoft.ServiceModel.DomainServices.Hosting.SoapXmlEndpointFactory,
Microsoft.ServiceModel.DomainServices.Hosting"
/>
</endpoints>
</domainServices>
Do not worry about the "system.serviceModel" warning; ignore it
Add the service reference. "But, which uri?" you ask. The address of your service is this one: [namespace of your ria service]-[classname of your ria service].svc where . are replaced with -. So, if I have created my service inside of a Services directory in my SL application and the namespace looks like this:
namespace myApplication.Web.Services
{
[EnableClientAccess()]
public class SuperService ....
then the address would be:
http://localhost[:port]/Services/myApplication-Web-Services-SuperService.svc
Let the tooling do the rest. If you get some funky errors then save and close VS and start again and it all works.
I hope that this is the answer that you are looking for.
The following solved my problem:
I created a new WP7 project added the wcf service.
Then I copied the Service References folder to the directory of my project that gave me this problem and restarted Visual studio and built the application.
You should get namespace errors inside your Reference.cs; just change the namespace to the current project namespace.
Related
We've been battling with a strange issue for a couple of days now. Have searched the net for answers but none seem to solve the error.
Our scenario is: our organization has a Silverlight 5 application, which was developed in VS 2010, and everything was working fine. It is actually running in our production servers.Recently we migrated our development machines to VS 2015, and the machines themselves (new ones for the dept). The OS is Windows 7, same as before.
At first we were welcomed with that nasty MatchTimeoutInMilliseconds error, due to the MS Framework. Eventually MS released the 4.6.2 Preview version which covered this issue.
Ok. So back to implementing the changes requested, we created a new method in our webservice, and it complied just fine. We do have the [OperationContract] and [DataContract] tags in place. There is a question posted and answered with the justification that these tags were missing.However, when we go to the SL app and update the WS reference, we get this "Custom tool error: Failed to generate code for the service reference ..."
Custom Tool Warning messages include
"Cannot import wsdl:binding..."
"Cannot import wsdl:port..."
"Cannot import wsdl:portType..."
"No endpoints compatible with Silverlight 5 were found. The generated client class will not be usable unless endpoint information is provided via the constructor."
We're puzzled, because then we thought we might have done something wrong, so we rolled back the changes, and updated the service reference with no changes, and we get the same error. The Referece.cs file is generated with no code, and all references to the webservice are no longer recognized by the compiler.
We've also read some posts that offer as a solution unchecking "Reuse types in referenced assemblies". Doing that does clear these errors, only to generate others, since our app was built on this premise.
We've also tried deleting the service reference and adding it back again, but to no avail.
Eventually we reverted the SL app to the point it was compiling, which was before updating the webservice reference, republished the WS with the new method, and manually added the new method to the Reference.cs file, tested it and it works.
This, however, should not be -the- solution. It's a hassle and prone to errors.
We'd appreciate any help in solving this matter, or an insight as to why this is happening.
thanks
The whole problem is that, for some reason I still haven't found, VS fails to generate the code for Reference.cs.
As a workaround, we've managed to generate the Reference.cs file by using the SlSvcUtil.exe tool, located (on my machine) at "c:\Program Files (x86)\Microsoft SDKs\Silverlight\v5.0\Tools".
In order to get the same code as the one generated before the migration, I've used the following command and options:
SlSvcUtil.exe my_ws_address /namespace:"*,my_class_namespace" /ct:System.Collections.ObjectModel.ObservableCollection`1 /r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v5.0\System.Windows.dll" /edb /ser:Auto
I didn't use the /out switch, but rather ran the command on my desired output directory. But you might want to look into that switch before running the command.
i got a folder with a WSDL file (and all the xsd files related to it) but i can't seem to generate a web service from it using the "Add service reference" option in VS2013 (also tried in 2008 just to test). I'm using .net 4.0.
i get multiple error such as:
Custom tool error: The global type ('WarningType') has been defined in both
'file:///D:/WSDL/AMA/2011Y/chameleon/AMA_CommonTypes.xsd' and
'file:///D:/WSDL/IATA/2010.1/chameleon/IATA_CommonTypes.xsd'.
They are different at './simpleContent/extension/#base'.
so, i was advised to use "Add Web reference" tool.
this works for some reason. i get no errors now.
But, the problem is that i found out that a web reference do not support WS-Security /WS-Adressing
(someone wrote this as a comment in how to add SOAP Security header) and i MUST specify in the header those elements.
Also, i keep reading not to use a web reference since this is an old technology.
So, does anyone know how to solve the errors I'm getting ?
There are multiple tools that generate service proxy objects. Apart from using Add Service Reference you can use command line tool svcutil.exe which is included as part of the visual studios installation for generating service objects.
Here is how to do this
http://msdn.microsoft.com/en-us/library/ff623148.aspx
This alternative command line approach will help you resolve issue related to WS-Security / WS-Adressing.
I'm busy writing a custom Windows Services to handle MSMQ messages on a server, but the installation (using InstallUtil) keeps failing with the following error:
"System.InvalidOperationException: Unable to get installer types in
the 'x'.exe assembly. The inner exception
System.Reflection.ReflectionTypeLoadException was thrown with the
following error message: Unable to load one or more of the requested
types. Retrieve the LoaderExceptions property for more information."
I am using 3 of my own assemblies in the service. All of them are set to 'Copy Local' and all other referenced assemblies are in the GAC. I have verified that all other referenced assemblies not in the GAC are in the the folder containing my services' .exe file.
I have also tried signing my assemblies (if that is worth anything...)
I have also looked around on Google, but in most cases the problem was either solved via a service pack, or installation of some proprietary software, which obviously solved the missing dependency issue.
I wrote a simple POC service, without referencing any 'outside' assemblies which worked fine...
I'm developing and testing on a Windows 7 machine.
Any ideas?
Thanks!
EDIT:
Ok weird... I was using PostSharp for exception handling and logging... I removed the references to PostSharp and my aspects, and it installed with no problem... o_O
Is there any reason why something like PostSharp will not play well with Windows Services?
Without the installer, have you tried registering your service with all dependent assemblies? were you successfully able to register?
If this has worked, then -
Is your service registration action is post install complete action in your installation authoring steps?
Sorry fo my english. I worked 2 days on this problem and i found that installutil works only if installutil and service and dependencies files in one directory.
installutil service -> works fine
installutil ServicePath\service -> dont work if dependencies in ServicePath directory.
Ok, I found the problem... I applied the same PostSharp aspect twice to a method. So I had Method1 and Method2, both have the [MyException] aspect applied. Method1 calls Method2 so the aspect is 'applied' twice, which didn't go down well with the Service Installer. I removed the aspect from Method2 and all worked fine!
This question already has answers here:
Log4Net in WCF not working
(6 answers)
Closed 9 years ago.
Within last few days I'm facing really weird problem, I did my best to overcome it, but it seem so abstract to me that I don't even know where to look any further. I've read all related threads here, on SO, and many other sites that google found for me. Case is pretty complicated, but please bear with me:
I work on a project which has MVC web portal front-end that is communicating with back-end infrastructure using WCF web services, some are written by us, some are WWF services. All services are using simple http binding. I was given a task that required me to change service's contract, and hence updating service reference. Update did not succeed, giving me following set of warnings/errors:
Warning 43 Custom tool warning: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. PathToProject\Reference.svcmap 1 1 PortalProjectName
Warning 44 Custom tool warning: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter
Error: The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
XPath to Error Source: //wsdl:definitions[#targetNamespace='namespaceDeclaredInService']/wsdl:portType[#name='IEntityListService'] PathToProject\Reference.svcmap 1 1 PortalProjectName
Warning 45 Custom tool warning: Cannot import wsdl:binding
Detail: There was an error importing a wsdl:portType that the wsdl:binding is dependent on.
XPath to wsdl:portType: //wsdl:definitions[#targetNamespace='namespaceDeclaredInService']/wsdl:portType[#name='IEntityListService']
XPath to Error Source: //wsdl:definitions[#targetNamespace='http://tempuri.org/']/wsdl:binding[#name='WSHttpBinding_IEntityListService'] PathToProject\Reference.svcmap 1 1 PortalProjectName
Warning 46 Custom tool warning: Cannot import wsdl:port
Detail: There was an error importing a wsdl:binding that the wsdl:port is dependent on.
XPath to wsdl:binding: //wsdl:definitions[#targetNamespace='http://tempuri.org/']/wsdl:binding[#name='WSHttpBinding_IEntityListService']
XPath to Error Source: //wsdl:definitions[#targetNamespace='http://tempuri.org/']/wsdl:service[#name='EntityListService']/wsdl:port[#name='WSHttpBinding_IEntityListService'] PathToProject\Reference.svcmap 1 1 PortalProjectName
Error 47 Custom tool error: Failed to generate code for the service reference 'EntityListService'. Please check other error and warning messages for details. PathToProject\Reference.svcmap 1 1 PortalProjectName
I've found that this can be solved by having web service not reuse types from referenced assemblies. I Did that, then I've found out that (ofc) I have ambiguous types references in code. Anyway, this solution I did just for test purposes, since reusing types from referenced assemblies is just what I want. So I checked reuse checkbox back and started experimenting.
From portal project I removed all references that caused problem (from which types were ought to be reused), than updating reference worked (it's pretty much equivalent to not reusing), build of course not.
Then I figured out that this may have something to do with some hidden error in any of these assemblies being part of the same solution. So I tested this hypothesis building one of these projects and referencing it from Portal as dll. All the same.
Then, by investigating some more I've found out that this error occurs also when I remove references to assemblies with types that I want to reuse and add reference to project "Resources" from portal (no types from this project are used in portal or web service).
Resources contained one class (attribute) and one resources file (cs+resx).
So now I have Portal project with added reference to resources, no reference to any project that originally caused error and error still occurs. Then I saw that access modifier in for resources file in resources project is set to Public. I switched it to internal, and then I successfully updated service reference. Problem is, that this have to stay public, since other projects use these resources, including these containing types that I want service to reuse.
While googling on this subject I've found people saying that these help:
restart VS
run VS with no admin privilages
uninstal VS 2012 RC and reinstall VS2010
delete and add reference from scratch, restarting VS between these
steps
In my case neither of these solutions helped.
From my point of view it is very strange, any help will be greatly appreciated, since, as for now I have no solution for this problem.
Edit:
In resources project I've made a proxy class, and make actual resources internal. That made build possible, and update reference worked when portal referenced only resources project. After adding references to other assemblies from project it's all the same.
It turned out that problem was caused by log4net.dll, which was built against .NET Framework 3.5. We made our own dll against .Net 4.0 and all problems are gone.
I successfully added a WCF Service Reference to my ASP.NET project, but I'm not able to use it.
I can't import the service referenece via using MyProject.MyService.
This worked in a standard Windows Form project and I now, that the requested service is working.
Thanks for your help.
Edit:
There occure Warnings during the generation of the service client
I think the "main" warning is the following
Warning 1 Custom tool warning: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension:System.ServiceModel.Description.DataContractSerializerMessageContractImporter
Error: Type 'Newtonsoft.Json.Linq.JToken' is a recursive collection data contract which is not supported. Consider modifying the definition of collection 'Newtonsoft.Json.Linq.JToken' to remove references to itself.
This warning comes only at the generation in an ASP.NET project. The generation works in my other projects.
It seems that this is a problem of a class I'm not responsible for. May I have to change the settings for the service reference creation or avoid some imports in the original WCF Service class?
We need some more information in order to troubleshoot this for you. Is the reference being added but you cannot use it?
I would suggest looking at the reference.cs file (under the service reference, you may need to tell solution explorer to show all files - little icon of the folders and files at the top) and seeing what namespace it has been generated with.
I think you're probably just not using the correct namespace to reference the client.
The other possibility: check for any compiler warnings, they might give you a clue as to what is going on.
EDIT: This seems to be an issue encountered by others. Do you have the json.net package installed?
Please see the following for details:
Getting "Recursive collection data contract" when referencing a WCF service with a slightly complex method