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

Dependency Injection error prevents me from passing an object to CStoreSCP #1682

Open
saschke opened this issue Nov 11, 2023 · 1 comment
Open

Comments

@saschke
Copy link

saschke commented Nov 11, 2023

Describe the bug
Whe creating an Instance of a CStoreSCP using this code

var storageConfiguration = new StorageConfiguration(StoragePath, FileNameExtension, AeTitle);

_server = DicomServerFactory.Create(
IpAddress, Port,
userState: storageConfiguration);

using the sample code of FO-Dicom only adding the userState - parameter it seems to work and the _server is listening but when I echo the _server I get an exception:

[ERROR] Exception listening for DICOM services, System.InvalidOperationException: Unable to resolve service for type 'System.Object' while attempting to activate 'DicomCommunication.DicomStorageScpNonStatic.DicomStorageScp+CStoreSCP'.
bei Microsoft.Extensions.DependencyInjection.ActivatorUtilities.GetService(IServiceProvider sp, Type type, Type requiredBy, Boolean isDefaultParameterRequired)
bei lambda_method(Closure , IServiceProvider , Object[] )
bei FellowOakDicom.Network.DicomServer1.CreateScp(INetworkStream stream) bei FellowOakDicom.Network.DicomServer1.d__56.MoveNext()

To Reproduce
Use the code above, if I leave 'userState: storageConfiguration' away it works but I should be able to pass information to the StorageSCP instance.

Expected behavior
I would expect this to work as I use the proper parameters.

for this version of access

public static IDicomServer Create(
string ipAddress,
int port,
string certificateName = null,
Encoding fallbackEncoding = null,
Logger logger = null,
object userState = null)
where T : DicomService, IDicomServiceProvider
{
return Setup.ServiceProvider.GetRequiredService().Create(ipAddress, port, certificateName, fallbackEncoding, logger, userState);
}

Can you tell me what I am missing?

Environment
Fellow Oak DICOM version: (e.g. 5.0.3.0 but I also get the same error in the newest version)
OS: (e.g. Windows 11)
Platform: (e.g. .NET Framework 4.7.2 but also .NET 7)

@saschke saschke added the new label Nov 11, 2023
@amoerie
Copy link
Collaborator

amoerie commented Nov 20, 2023

Can you please review the diagnostic questions here: #1611
You're probably running into one of these root causes.

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

No branches or pull requests

2 participants