Search code examples
c#nugettypeinitializeexceptiontypeinitializertypeinitializationexception

Is there a tool or strategy for figuring out all .dll and nuget packages that a project needs to reference?


I am using some third party .dll that references several nuGet packages internally. In order for me to be able to use that third party .dll, I need to somehow figure out what NuGet packages I need to install.

Is there a tool or strategy that will assist me in determining which NuGet packages I am missing?

I have attempted to run my program, and an exception was thrown that said I was missing a package. I installed that package and don't get that error anymore. However, I do get an error that says:

The type initializer for 'SomeStaticClass' threw an exception

I suspect that I am still missing some references. Any ideas on how to figure out what references or NuGet packages I'm missing?


Solution

  • What I do in these circumstances is use a tool called "Just Decompile" (there are many of these tools, this is just the one I currently use.)

    It integrates in to Windows Explorer so you can right-click on a managed DLL/EXE and the context menu will popup and give you an option to "Open with Just Decompile" At that point, a UI will pop up and show you everything it references: managed AND native libraries:

    Just Decompile

    So you can see here that the "LCCShell.exe" depends on a couple managed libraries that are not available to be resolved. I would need to figure out how to get those. Most of the time the namespace is all I need to find it in Nuget. It also show you the native libraries as well, which is really convienient.