Error adding service reference using existing types
I'm trying to add a service reference to a service I have in my solution with the "reuse types in referenced assemblies" checked.
Problem is that it doesnt generate any code, the reference.cs file is empty, and i get an error stating the tool failed to generate my service reference.
There's 2 more warnings :
Custom tool warning: AssemblyResolveEvent handlers cannot return Assembl开发者_运维问答ies loaded for reflection only.
and
Custom tool warning: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
What could be the problem, and how could I solve it? Thanks for your help
--edit In fact, it looks like VS is looking some dll somewhere, often when I close all instances of devenv and try again, the generation succeed... If someone has an idea where this weird behavior comes from, I'm all hears...
For troubleshooting, try doing the same thing but using the SvcUtil command line utility. Try using SvcUtil with just the WSDL switch to make sure it will generate the proxy class. Next, try it as shown in the article. You'll probably need to add multiple -r switches to include all the DLLs required (i.e. other assemblies you've created that are referenced by your project DLL).
Using this approach, you'll either discover the missing DLL or find that you have a type conflict with an existing type causing SvcUtil to fail.
I had a similar problem when adding a service and found I had a reference to an old service that no longer existed in my application. I tried to delete the reference and got the same error. So I deleted the section of the app.config referred to in the error and deleted the reference again and this time it worked. After that adding the reference worked fine. I was also reusing references and had references to DLL's that had been updated, perhaps that was the cause.
Anyway who uses WCF nowadays :-)
精彩评论