Skip to content

.net 10.0 issue with Channeltype does not inherit from channel #97

Closed

Description

@gerbaten

i am using named pipes i moved to .net10.0 and now i get after a few calls System.ArgumentException: channelType does not inherit from Channel at ServiceWire.NamedPipes.NpClient1..ctor(NpEndPoint npAddress, ISerializer serializer, ICompressor compressor, ILog logger, IStats stats

according to github co pilot the solution might be to cache createdtype.
calling Type t = proxyBuilder.TypeBuilder.CreateTypeInfo(); multiple times might caused the error for .net10.0

suggested changes by copilot

`
internal sealed class ProxyBuilder
{
public string ProxyName { get; set; }
public Type InterfaceType { get; set; }
public Type CtorType { get; set; }
public AssemblyBuilder AssemblyBuilder { get; set; }
public ModuleBuilder ModuleBuilder { get; set; }
public TypeBuilder TypeBuilder { get; set; }

// Cache the created type to avoid calling CreateTypeInfo() multiple times
private Type _createdType;
private readonly object _lockObject = new object();

public Type GetOrCreateType()
{
    if (_createdType == null)
    {
        lock (_lockObject)
        {
            if (_createdType == null)
            {
                _createdType = TypeBuilder.CreateTypeInfo();
            }
        }
    }
    return _createdType;
}

}
`

`
private static TInterface CreateProxy(ProxyBuilder proxyBuilder, object channelCtorValue, ISerializer serializer, ICompressor compressor, ILog logger, IStats stats) where TInterface : class
{
//create the type and construct an instance
Type[] ctorArgTypes = new Type[] { typeof(Type), proxyBuilder.CtorType, typeof(ISerializer), typeof(ICompressor), typeof(ILog), typeof(IStats) };

// Use the cached type instead of calling CreateTypeInfo() repeatedly
Type t = proxyBuilder.GetOrCreateType();

var constructorInfo = t.GetConstructor(ctorArgTypes);
if (constructorInfo != null)
{
    TInterface instance = (TInterface)constructorInfo.Invoke(new object[] { typeof(TInterface), channelCtorValue, serializer, compressor, logger, stats });
    return instance;
}
return null;

}
`

Activity

  1. tylerje commented on Nov 18, 2025

    @tylerje
    Member

    Thanks for the report. Are you on .NET 10 on client and server? I won't have time to review this until January. You're welcome to fork the code and test the suggestion. Let me know how that goes.

  2. gerbaten commented on Nov 18, 2025

    @gerbaten
    Author

    I currently solved it on our side by making the services singletons that use the proxies. I think that is a good solution.
    I use client .net 10 and server is framework net48

  3. tylerje commented on Nov 18, 2025

    @tylerje
    Member

    Excellent. Yes. That is the correct pattern.

  4. yueeng commented on Nov 21, 2025

    @yueeng

    I also have the same issue. Both my server and client are using .NET 10. When this error occurs, I need to restart the one that has the error—it could be the server or the client.

  5. tylerje commented on Nov 21, 2025

    @tylerje
    Member

    @yueeng did you try the solution @gerbaten found? See above.

  6. IvoTops commented on Mar 9, 2026

    @IvoTops
    Contributor

    We fixed the issue in our setup. Only one line of ServiceWire code needs to be changed. See pull request.

  7. wouterroos commented on May 12, 2026

    @wouterroos

    @tylerje Any chance you can merge #98 and push a new release? The change seems simple/low impact. Happy to assist if that can help move this issue forward!

  8. tylerje commented on Aug 18, 2026

    @tylerje
    Member

    The reported .NET 10 channel validation failure was fixed before 6.0.0 by replacing the custom inheritance walk with typeof(Channel).IsAssignableFrom(channelType). For 6.0.1, targeted regression coverage now repeatedly creates proxies from a Channel subclass to exercise both the validation and repeated CreateTypeInfo() path on .NET 10 and .NET Framework 4.8. Closing this as completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions