tylerjensen/ServiceWire

Error passing System.Uri between .NET 4.6.2 and .NET 8

Closed this issue · 5 comments

Just passing an instance of System.Uri between .NET 4.6.2 and .NET 8 processes gives this:

System.InvalidCastException: Object must implement IConvertible.
   at ServiceWire.Aspects.InterceptChannel.InvokeMethod(String metaData, Object[] parameters)

We found a possible reference to this issue in https://github.com/SubSonic-Core/SubSonic.Core.ServiceWire

implements additional typemapping so System.Uri can be mapped between framework and netcore runtimes

but that's an outdated fork, and it's unclear why that fix hasn't been merged here in 4 years.
Any ideas much appreciated.

Thanks for the quick response @tylerje!

System.Uri can provide platform-specific representations of a URI, which is required in our case. Also, it helps to have compile-time certainty about the nature of a string. The workaround is to do serialization "manually", but I'd rather delegate that to the transport level. Could you give me some ideas about the custom serializer option?

Of course, you will need to inject your custom serializer in the client and host constructors. Test your serializer between the two runtimes, and Bob's your uncle.

The reason I don't burden the default serializer with multiple type resolvers between multiple runtimes is there are far too many combinations and that would bloat the default to cover rare edge cases.