Comments (6)
I've noticed it also matters if the app in question is a web application versus a regular command line / desktop application (binaries are within the /bin folder for a web app, etc).
I think in my old local copy I had modified the loader code so that I could pass in a path. I also had it do some extra logging around what was found so I could debug it in production. Also, at that time, I had the loader specifically choose to examine one DLL or the other based on the bitness of the current process. That allowed for easy deployments in x86 or x64 environments (or x64 but with the IIS app in 32-bit mode) without having to worry about anything.
from fo-dicom.
I was doing a WADO service and had trouble reading the DICOM codecs, the solution to this was, in the class "DicomTranscoder", method "LoadCodecs", change this line "Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)" by "Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath)", this solution work fine in any app(console/desktop/web)
from fo-dicom.
@maikel87 Thanks for your input!
from fo-dicom.
Also there is too many complaints about VC runtime, there is no direct instructions for devs to pre-install VC runtime (x86 or x64)
I don't know if Nuget supports bundling x86 and x64 on the same package or we should have 2?
from fo-dicom.
Thinking about this, could we embed the x64 and x86 DLLs as resources in the dicom.dll assembly? At runtime, when they're first required (which may be never, depending on the app), fo-dicom checks the current process' bitness, extracts the x86 or x64 DLL and loads it.
See here http://blogs.msdn.com/b/microsoft_press/archive/2010/02/03/jeffrey-richter-excerpt-2-from-clr-via-c-third-edition.aspx
One commenter asks about using this for libraries (like fo-DICOM). We just need to have the fo-DICOM methods that might call into those DLLs first make a call to some thread-safe init() function.
Also, to round out the reading...
http://stackoverflow.com/questions/9228423/how-to-use-an-dll-load-from-embed-resource
And
http://stackoverflow.com/questions/6893060/load-an-assembly-from-an-embedded-resource
from fo-dicom.
@IanYates I would argue that embedding the DLLs as resources would make the DICOM.dll unnecessarily big in those cases when image codecs are not requested.
I have looked a little closer into this issue this morning. I created a unit test for the DicomTranscoder.GetCodec
method, and it is then clear that even in this simple unit test scenario native assembly loading fails. As @maikel87 hinted, the problem appears to lie in the use of Assembly.Location
. Assembly.Location
refers to the location from which the assembly is loaded, which may very well be a shadow-copy location (which is often the case for unit testing within Visual Studio or ASP.NET projects, if I am not mistaken). Assembly.CodeBase
on the other hand refers to the original location of the assembly, which is really what the DicomTranscoder.LoadCodecs
method should be looking for when the path
argument is null
.
I am preparing a PR where the path
setting in LoadCodecs
is changed to the following:
path = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().EscapedCodeBase).LocalPath);
This is basically what @maikel87 suggested, except that I am using EscapedCodeBase
instead of CodeBase
, since the escaped version should be more fail-safe in the URI context.
This fix did the trick for the unit test. It would be really good if someone could also verify that it improves the situation for web projects.
from fo-dicom.
Related Issues (20)
- Print SCU layout Images not rendering in the correct order
- Add Support to set dicom client ip HOT 2
- Set Time Out duration for requested association for C-Echo / C-Store HOT 4
- Question - How to Load PixelData as Fragments HOT 1
- ImageSharp is not free software - Disclaimer? HOT 5
- DICOM files where numeric tags contain "NaN" (don't ask) cause exceptions
- Race condition in GenericGrayscalePipeline
- Corrupt Multi-frame File - Consistent for all image sizes. HOT 2
- How to monitor the time for a SCU client to transfer multiple files at a time on the SCP Server side HOT 3
- Code in fo-dicom to apply window width and center on an image HOT 1
- TCP listener stuck while processing TLS handshake HOT 4
- HTJ2K Throwing exception HOT 2
- The SCU client transmits images to the fo-dicom c-store-scp, and the speed decreases sequentially after each task is transmitted
- Korean Hangul characters incorrectly read from dicom file HOT 2
- fo-dicom v5 Dependency Injection Documentation HOT 3
- DicomServer performance regression HOT 6
- Microsoft Code Analysis HOT 2
- Creating a TCP connection using `DicomClient.SendAsync()` does not take `AssociationRequestTimeoutInMs` into account HOT 3
- DicomValidation for VR PN HOT 17
- dataset AddOrUpdate not find Encod args HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fo-dicom.