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

DLL "Dicom.Native" not found when rendering an image on .Net 4.8 (x64) #1680

Open
lalenzos opened this issue Nov 6, 2023 · 3 comments
Open
Labels

Comments

@lalenzos
Copy link

lalenzos commented Nov 6, 2023

Describe the bug
I'm currently facing the problem that I cannot convert/render a DICOM image to a png/jpg. I'm following the documentation, but unfortunately I'm always getting the Exception of type "DllNotFoundException" in Dicom.NativeCodecs.dll, stating that "the DDL 'Dicom.Native' could not be loaded: the module could not be found.".
The documentation also describes that the "Dicom.Native-win64.dll" or "Dicom.Native64.dll" should exist on an x64 platform, but both are not existing.
I'm refering to this: https://github.com/fo-dicom/fo-dicom/wiki/Native-codecs-on-.NET

To Reproduce
(attached example application (see line 45 "dicomImage.RenderImage()") with example Dicom files)
DicomRenderImageTest.zip

Expected behavior
Rendering/Converting the DICOM format into an image format (jpg, png, ...).

Screenshots or test DICOM files
image

Environment
fo-dicom - version 5.1.1
fo-dicom.Codecs - version 5.10.8
fo-dicom.Imaging.ImageSharp - version 5.1.0
OS: Windows 11 Pro
Platform: .NET Framework 4.8 - x64

Thanks

@lalenzos lalenzos added the new label Nov 6, 2023
@anishsingh0302
Copy link

I am also facing same error after upgrading to latest version of fo-dicom.
fo-dicom - version 5.1.1
fo-dicom.Codecs - version 5.10.8
fo-dicom.Imaging.ImageSharp - version 5.1.0

System.DllNotFoundException: Unable to load DLL 'Dicom.Native': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

Stack Trace: 
DicomJpeg2000NativeCodec.Memset(Void* ptr, Int32 value, UInt32 num)
DicomJpeg2000NativeCodec.Decode(DicomPixelData oldPixelData, DicomPixelData newPixelData, DicomCodecParams parameters)
DicomTranscoder.Decode(DicomDataset oldDataset, DicomTransferSyntax outSyntax, IDicomCodec codec, DicomCodecParams parameters)
DicomTranscoder.Transcode(DicomDataset dataset)
DicomTranscoder.Transcode(DicomFile file)

Anyone of them found any solution?

@udiatcimd
Copy link

Facing the same problem after updating to the latests version of fo-dicom

I get the error trying to use dicomfile.Clone

I was working with fo-dicom: 5.0.3 and fo-dicom.codecs: 5.0.3 but since I updated to the latest version and now i get the same error when i try to clone a dicomfile:

dicomFile.Clone(DicomTransferSyntax.ExplicitVRLittleEndian);

I initialize the transcodermanager like this (it was working just fine on previous versions):

                new DicomSetupBuilder()
                .RegisterServices(s => s.AddFellowOakDicom().RemoveAll<FellowOakDicom.Imaging.NativeCodec.NativeTranscoderManager>())
                .Build();

Maybe we have to wait untill fo-dicom.codecs releases a 5.1.1?

thanks!

@amoerie
Copy link
Collaborator

amoerie commented Jan 22, 2024

@lalenzos

I upgraded your solution + csproj to the SDK style format (using https://github.com/hvanbakel/CsprojToVs2017 ) and updated to the latest fo-dicom and fo-dicom.Codecs.
Then, I cleaned up your csproj properties to reduce the number of configurations. AnyCPU will never work, because you will always need 32 bit or 64 bit with the codecs. And setting PlatformTarget to x64 under the AnyCPU configuration is ... confusing. Visual Studio used to have bugs when there was no AnyCPU configuration, but those are fixed as far as I'm aware. JetBrains Rider can definitely handle it as well.

Anyway, here is a working zip file that contains your sample project where the codecs work. So it is definitely a matter of configuration. I did not find the minimal set of changes you guys need to get this working, I'll leave that exercise to you.

DicomRenderImageTest2.zip

@anishsingh0302 and @udiatcimd See above. The codecs work on .NET Framework. We also have unit tests that prove this.

Maybe, and this is just a suspicion, the old .csproj format is causing trouble here. Both the unit tests and my working sample use the SDK style. But I don't have time left to verify this, and it would also surprise me. But I have been surprised before. :-)

@amoerie amoerie added invalid and removed new labels Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants