Home Dashboard Directory Help
Search

VS2012 - Add service reference -> Discover (services in solution) feature creates empty proxy by Royi Mindel


Status: 

Closed
 as Duplicate Help for as Duplicate


2
0
Sign in
to vote
Type: Bug
ID: 790187
Opened: 6/14/2013 6:43:55 AM
Access Restriction: Public
2
Workaround(s)
view
1
User(s) can reproduce this bug

Description


I have an azure cloud solution with 2 roles,
WcfService Role, WebSite(MVC4) Role

I need my website role to have a service reference of my wcfservice role.
this cannot be done, and the proxy comes out empty while the service is offline.

If the service is online - the solution is locked and you cannot add new service reference (because the solution running means both roles running).

as a work around i run svcutil on the online service into a new proxy file, and copy that file after to my solution.
I have to do that with every change to my service instead of the "update web reference feature"...
Details
Sign in to post a comment.
Posted by Microsoft on 6/21/2013 at 4:17 PM
I would not have any performance conerns for the generated applications based on unchecking the "reuse reference" for the generated app(*). Essentially what the feature does is to check for all types in the reference assembly, compare them types exposed by the service, and if they match, instead of generating a new type as part of the proxy, use the type in the referenced assembly.

The most likely consequences of unchecking assemblies are:
1) you actually depended on the type being reused, which will cause a compile time error if you are not using dynamic features in C# and/or "option strict off" settings in Visual Basic.
2) you didn't depend on the type being reused, the code compiles just fine, but you end up with an extra couple of data contract classes in your code leading to a marginally larger assembly.

Now that I know what I'm looking for, I can find other customer repored (and internal) bugs that indicate that the issue has alread been addressed. See http://connect.microsoft.com/VisualStudio/feedback/details/775691/add-service-ref-in-mvc4-application-fails-to-generate-client-code for more information.

Best regards,
Johan Stenberg
Software Design Engineer, Microsoft Visual Studio

(*) as always when it comes to performance, one can come up with degenerate cases aimed at specifically cause performance problems where you *may* be able to measure runtime performance impacts.
Posted by Royi Mindel on 6/20/2013 at 2:46 PM
Thank you so much, i got it to work by unchecking the "Reuse types"
It will be much easier to work on my project now :)

a few more questions to close things off -
unchecking the reuse references - will it have any performance ramifications?
and - will you (Microsoft) fix the types so that the "Internet Template" and default WCF Role work together "OutOfTheBox"?

Again - Thanks a lot , you have been great help! :)

Best Regards
Royi Mindel
Posted by Microsoft on 6/20/2013 at 12:24 PM
Royi,

again, thanks for reporting this issue to us. With the updated repro steps, I was able to find out what is going on.

If you open the error window, you should see a set of warnings and an error message. The error message indicates that something did not go well with the code generation:

Error    4    Custom tool error: Failed to generate code for the service reference 'ServiceReference1'. Please check other error and warning messages for details.    c:\Repro\WindowsAzure2\MvcWebRole1\Service References\ServiceReference1\Reference.svcmap

In addition, there are also a couple of warnings that give a little more information about what is going on, specifically:

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.
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:portType[@name='IService1']    c:\Repro\WindowsAzure2\MvcWebRole1\Service References\ServiceReference1\Reference.svcmap

The root cause of the problem is the fact that there is a type in the Newtonsoft.Json assembly that cannot be used as a "reused type". By default, Visual Studio will try to reuse types from all referenced assemblies in order to avoid generating duplicate types as part of your proxy.

You can control this behavior in the "Configure Service Reference" dialog. See http://msdn.microsoft.com/en-us/library/bb514724.aspx for more information.

By selecting the "Reuse types from specific assemblies" option and only check the assemblies that contain types that your service exposes as data contracts (i.e. mscorlib + system) should resolve your issue.

Best regards,
Johan Stenberg
Software Design Engineer, Microsoft Visual Studio
Posted by Royi Mindel on 6/19/2013 at 11:25 PM
Hi again,

After trying to reproduce the issue again, i found out that it happens to me only when choosing "Internet Application" in the MVC 4 templates menu,

When i chose "Empty" it generated the service proxy correctly.
I will reproduce this a couple more times, and add the last solution to this post.
-I tried this a couple more times, the issue is only when choosing the Internet Application template for MVC4

adding a solution with both MVC4 Empty Template with the proxy generated, and MVC4 InternetTemplate with the empty proxy generated for the same WCF Service role

Thanks again :)
Royi
Posted by Royi Mindel on 6/19/2013 at 10:58 PM
Hi Johan,

The fault is on my part, i forgot to mention this happens on VS2012 Express For Web, and not VS2012 Ultimate.
Also I am using the Azure Tools - October 2012 Release.

There are no errors in the error list,
And those are the exact steps i took and posted the solution with the empty proxy here

Best regards
Royi Mindel.
Posted by Microsoft on 6/19/2013 at 6:21 PM
Royi,

Thanks for reporting this issue. I have tried, but unfortunately failed, to reproduce the issue you are experiencing. The steps I followed using Visual Studio 2012 Ultimate with Visual Studio 2012 Update 2, Azure SDK and tools v2.0:

- Create a new Windows Azure Cloud Service
- Add a new ASP.NET MVC 4 Web Role project (C#, targeting .NET FX 4.5)
- Add a new WCF Service Web Role project (C#, targeting .NET FX 4.5)
- Build the WCF Service Web Role project
- Add a service reference from the ASP.NET Web Role project to the WCF Service Web role found in the current solution by clicking "Discover" in the "Add Service Reference" dialog.

Result: Proxy code is correctly generated

I also tried the same steps after having published the solution to Azure with the same results.

I suspect that there is something that is different in our environments/setups, or some missing steps required to reproduce the issue that is causing the difference in behavior, so if you could please provide the version of the Azure Tools for Visual Studio that you are using, it would be great.

Also, are there any errors or warnings in the "Error List" window (view -> error list) after you have added the service reference?

Best regards,
Johan Stenberg
Software Design Engineer, Microsoft Visual Studio
Posted by Microsoft on 6/16/2013 at 11:28 PM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by Microsoft on 6/14/2013 at 6:51 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.
Posted by Microsoft on 6/20/2013 at 12:24 PM
Royi,

again, thanks for reporting this issue to us. With the updated repro steps, I was able to find out what is going on.

If you open the error window, you should see a set of warnings and an error message. The error message indicates that something did not go well with the code generation:

Error    4    Custom tool error: Failed to generate code for the service reference 'ServiceReference1'. Please check other error and warning messages for details.    c:\Repro\WindowsAzure2\MvcWebRole1\Service References\ServiceReference1\Reference.svcmap

In addition, there are also a couple of warnings that give a little more information about what is going on, specifically:

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.
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:portType[@name='IService1']    c:\Repro\WindowsAzure2\MvcWebRole1\Service References\ServiceReference1\Reference.svcmap

The root cause of the problem is the fact that there is a type in the Newtonsoft.Json assembly that cannot be used as a "reused type". By default, Visual Studio will try to reuse types from all referenced assemblies in order to avoid generating duplicate types as part of your proxy.

You can control this behavior in the "Configure Service Reference" dialog. See http://msdn.microsoft.com/en-us/library/bb514724.aspx for more information.

By selecting the "Reuse types from specific assemblies" option and only check the assemblies that contain types that your service exposes as data contracts (i.e. mscorlib + system) should resolve your issue.

Best regards,
Johan Stenberg
Software Design Engineer, Microsoft Visual Studio
Posted by Royi Mindel on 6/14/2013 at 6:45 AM
Run the solution,

use in command line the "svcutil" to generate external proxy file.

stop the solution.

copy the external file to the solution.
File Name Submitted By Submitted On File Size  
WindowsAzure1.rar 6/14/2013 20.58 MB
WindowsAzure8.rar 6/19/2013 21.82 MB