Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Locate not properly using ExtraData #313

Open
JBurlison opened this issue Oct 16, 2023 · 2 comments
Open

Locate not properly using ExtraData #313

JBurlison opened this issue Oct 16, 2023 · 2 comments

Comments

@JBurlison
Copy link

I am getting an exception on this line:

e.Client.ClientSession = _container.Locate<IClientSession>(new { clientSocket = e.Client });

I am registering my object:

_ = builder.Export<ClientSession>().As<IClientSession>();

And my constructor

public ClientSession(ClientSocket clientSocket, PacketBuffer packetBuffer, ClassFactory classFactory)

I am giving it the clientSocket object but its trying to construct it.

Here is the constructor of that. Notice the first parameter is TcpClient.

public ClientSocket(TcpClient client, ILogger logger, ActionBlock<DataReceivedEventArgs> actionBlock)

From the looks of the error, its attempting to construct the TcpClient for the ClientSocket even though I passed it in with my extra data.

2023-10-16 04:37:16.749 -04:00 [ERR] Error processing data from client
System.ArgumentException: An invalid IP address was specified. (Parameter 'address')
   at System.Net.IPAddress..ctor(ReadOnlySpan`1 address)
   at lambda_method1067(Closure, IExportLocatorScope, IDisposalScope, IInjectionContext)
   at Grace.DependencyInjection.Impl.InjectionScope.InternalLocate(IExportLocatorScope scope, IDisposalScope disposalScope, Type type, ActivationStrategyFilter consider, Object key, IInjectionContext injectionContext, Boolean allowNull, Boolean isDynamic)
   at Grace.DependencyInjection.Impl.InjectionScope.Grace.DependencyInjection.IInjectionScope.LocateFromChildScope(IExportLocatorScope childScope, IDisposalScope disposalScope, Type type, Object extraData, ActivationStrategyFilter consider, Object key, Boolean allowNull, Boolean isDynamic)
   at Grace.DependencyInjection.Impl.ActivationStrategyDelegateCache.FallbackExecution(ImmutableHashTree`2 currentNode, Type type, IExportLocatorScope scope, Boolean allowNull, IInjectionContext context)
   at Grace.DependencyInjection.Impl.ActivationStrategyDelegateCache.ExecuteActivationStrategyDelegateWithContext(Type type, IExportLocatorScope scope, Boolean allowNull, IInjectionContext context)
   at Grace.DependencyInjection.Impl.InjectionScope.Locate(Type type, Object extraData, ActivationStrategyFilter consider, Object withKey, Boolean isDynamic)
   at Grace.DependencyInjection.Impl.InjectionScope.Locate[T](Object extraData, ActivationStrategyFilter consider, Object withKey, Boolean isDynamic)
@JBurlison
Copy link
Author

Looks like its not properly using my extra data as an override object, its opting to try and create the ClientSocket and part of the constructor for ClientSocket is a TCPClient and that needs a IPAddress.

Is there a way to not have grace try and construct this or is it a bug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant