WCF - compiler can't find TChannel

  • Thread starter Thread starter Jeff Jarrell
  • Start date Start date
J

Jeff Jarrell

I want to provide a helper to apply a certificate to svcutil generated
class(s) that derives from ClientBase<TChannel>. But the compiler can't
find "TChannel". I have System.ServiceModel referenced, it finds ClientBase.

The stub looks like this... Any ideas appreciated. Thanks.

using System;
using System.Collections.Generic;
using System.Text;
using System.ServiceModel;

namespace whi.pw.core.webutil
{
public class CertificateResolver
{
public static void Apply(ClientBase<TChannel> proxy)
{
}
}
}
 
Jeff,

This is an issue with not defining the type parameter TChannel. To fix
this, you would do:

public static void Apply<TChannel>(ClientBase<TChannel> proxy) where
TChannel : class

The constraint on TChannel comes from the constraint on the type
parameter TChannel in the ClientBase class.
 
Ok, that did the trick but I don't quite know what it means. Might you
point me to a reference on what the "where TChannel : class". Not so much as
TChannel, just what the "where" means on the method declaration.

thanks,
jeff

Nicholas Paldino said:
Jeff,

This is an issue with not defining the type parameter TChannel. To fix
this, you would do:

public static void Apply<TChannel>(ClientBase<TChannel> proxy) where
TChannel : class

The constraint on TChannel comes from the constraint on the type
parameter TChannel in the ClientBase class.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Jeff Jarrell said:
I want to provide a helper to apply a certificate to svcutil generated
class(s) that derives from ClientBase<TChannel>. But the compiler can't
find "TChannel". I have System.ServiceModel referenced, it finds
ClientBase.

The stub looks like this... Any ideas appreciated. Thanks.

using System;
using System.Collections.Generic;
using System.Text;
using System.ServiceModel;

namespace whi.pw.core.webutil
{
public class CertificateResolver
{
public static void Apply(ClientBase<TChannel> proxy)
{
}
}
}
 
Nicholas,
Ok, No need to follow up. I found the reference. The where relates to a
contraint on the Generic interface.

Thanks.

Jeff Jarrell said:
Ok, that did the trick but I don't quite know what it means. Might you
point me to a reference on what the "where TChannel : class". Not so much
as TChannel, just what the "where" means on the method declaration.

thanks,
jeff

Nicholas Paldino said:
Jeff,

This is an issue with not defining the type parameter TChannel. To
fix this, you would do:

public static void Apply<TChannel>(ClientBase<TChannel> proxy) where
TChannel : class

The constraint on TChannel comes from the constraint on the type
parameter TChannel in the ClientBase class.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Jeff Jarrell said:
I want to provide a helper to apply a certificate to svcutil generated
class(s) that derives from ClientBase<TChannel>. But the compiler can't
find "TChannel". I have System.ServiceModel referenced, it finds
ClientBase.

The stub looks like this... Any ideas appreciated. Thanks.

using System;
using System.Collections.Generic;
using System.Text;
using System.ServiceModel;

namespace whi.pw.core.webutil
{
public class CertificateResolver
{
public static void Apply(ClientBase<TChannel> proxy)
{
}
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top