0

In a .net 4.5 project I'm trying to create a WCF service reference that reuses types compiled in .net 4.0, but I can't get Visual Studio to reuse the 4.0 types in the service proxy.

I can instantiate the types just fine, but the service reference generator refuses to pick them up. If I add the same service to a .net 4.0 project, the types are successfully reused.

Does anybody know how to get a .net 4.5 generated service proxy to reuse .net 4.0 types?

Ryan Michela
  • 8,284
  • 5
  • 33
  • 47
  • When you say refuses does that throw any error or warning? – Praburaj Sep 13 '13 at 14:26
  • No errors or warnings. The service proxy generates just fine, but it doesn't reuse any types. – Ryan Michela Sep 13 '13 at 16:27
  • If you have a direct reference to your service contract I would recommend you forego using VS Add Service Reference. I personally always directly use `ChannelFactory` when I control both Client and Server side. – Aron Oct 20 '13 at 05:13

2 Answers2

0

I wonder if it has anything to do with useLegacyV2RuntimeActivationPolicy. I'm not sure if this will help your issue in WCF, but try sticking this in your .config file

<configuration>
    <startup useLegacyV2RuntimeActivationPolicy="true">
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
    </startup>
</configuration>

Detailed a bit better here: What does 'useLegacyV2RuntimeActivationPolicy' do in the .NET 4 config?

Community
  • 1
  • 1
Arkiliknam
  • 1,805
  • 1
  • 19
  • 35
0

Have you tried SvcUtil command line with /rtag

SvcUtil http://localhost/Service.svc /r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Data.dll" /r:"..\Reference Assemblies\Service.DataContracts.dll"

/r with SvcUtil adds the specified assembly to the set of assemblies used for resolving type references. If you are exporting or validating a service that uses 3rd-party extensions (Behaviors, Bindings and BindingElements) registered in configuration, use this option to locate extension assemblies that are not in the GAC.

For more details, refer msdn SvcUtil

Make sure referenced dll are in physical location from where it is refernced, works for me. Hope it will help you.

Pranav Singh
  • 17,079
  • 30
  • 77
  • 104