0

I have a somewhat convoluted issue where I need to call a WCF web service from a SQL Server 2005 stored procedure.

While researching I discovered that the only version of .NET SQL Server 2005 will natively support it 2.0 - yet I needed to use a client to consume the web service written for .NET 4. After playing around with some workaround to try to get SQL Server to recognize a .NET 4 DLL I decided to simply create a .NET 2 CLR stored procedure and use a wrapper class written in .NET 4 exposed as COM in order to call my web service.

I found several guides dealing with how to use a .NET 4 dll with .NET 2 as a COM dll (link, link) yet am still struggling.

My "wrapper class" (.NET 4) looks like this:

namespace Wrapper
{
    [Guid("4C1D992C-4965-49B2-A694-33810A3B9775")]
    [ComVisible(true)]
    public class WrapperClass
    {
         public bool Process(Guid ID)
         {
         }
    }
}

I've added the app.manifest file as suggested by the second link above. However, when I add the generated DLL to my .NET 2 sql server project, it fails to build with the following message:

1>c:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1578,5): Warning:  MSB3274: The primary reference "Wrapper" could not be resolved because it was built against the ".NETFramework,Version=v4.0" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v2.0".

What am I doing wrong here? I tried not adding the DLL as a reference at all but then the code does not even compile.

Alternatively, is there another (easier) way I can approach this issue?

EDIT: I can't directly add a web reference either:

enter image description here

Mansfield
  • 14,445
  • 18
  • 76
  • 112
  • Does your web service generate a WSDL file? – John Koerner Jan 29 '13 at 19:22
  • @JohnKoerner Yes it does. I have a working client that consumes it properly, except it requires `System.ServiceModel.dll` which .NET 2 doesn't have. – Mansfield Jan 29 '13 at 19:24
  • 1
    You could try using the WSDL to Proxy class tool:http://msdn.microsoft.com/en-us/library/aa529578.aspx – John Koerner Jan 29 '13 at 19:33
  • @JohnKoerner I'd already used svcutil.exe to generate a class from .NET 4. I'll look into using WSDL though...can't seem to find the file at the moment. – Mansfield Jan 29 '13 at 19:40

1 Answers1

0

I ended up just using John Koerner's suggestion and generating a client using WSDL that didn't use System.ServiceModel. As a result I made my CLR assembly .net 2.0 and it worked fine.

Community
  • 1
  • 1
Mansfield
  • 14,445
  • 18
  • 76
  • 112