.NET error in Event Viewer, "filenotfoundexception" "typeinitializationexception"

nope no 1 Reputation point
2023-01-17T18:30:35.1266667+00:00

I'm at the end of my rope here.

Details:

Using Microsoft Visual Studio Installer Projects

Windows 10 is the target system, x86 is the build target, x64 is the windows machine.

I've built and deployed this installer with my projects into this machine before, and others just like it. But this one keeps throwing this error over and over, with few details.

On the target machine, It lists a DLL i'm deploying as the one that is "missing."

The DLL in question is on the disk, in the same location as all the other DLL's.

When i try to register it manually, it says it can't find it or it cannot be loaded because of a dependency.

When using dependency walker, and fuslogvw, i see no errors related to the problem at hand. Visual studio also agrees, there are no missing dependencies in my dependency list.

I could be mis-using fuslogvw, as it was my first try at using it, but i don't think so:

When selecting "log failed bindings to disk" there are no entries, and when logging all bindings to disk, i see the binding for the dll in question, in the log, and the log says it bound successfully, with bind result hr=0x00

Questions:

  1. How can explicitly identify the "missing" dependency that it refuses to list, if fuslog, dependency walker, and visual studio itself tell me there aren't any.
  2. If this isn't a missing dependency, how can i get windows to explicitly tell me whats wrong instead of giving me a generic error?

I tried the following:

    catch (Exception ex)
               {
                   EventLog.WriteEntry("Application", "Caught filenotfoundexception in Program.cs" + "\nMessage: " + ex.Message + "\nSource: " + ex.Source + "\nInner exception: " + ex.InnerException + "\nSpecific exception (HRESULT): " + ex.HResult);
                   String myBase = ex.GetBaseException().ToString();
                   EventLog.WriteEntry("Application", "Caught filenotfoundexception in Program.cs" + "Inner exception's exception: " + ex.InnerException.InnerException  +  "Base Exception: " + myBase);

But that was all the information I could extract and it told me nothing more than the event log was already telling me on its own.

  1. If 1 and 2 aren't possible, can I get visual studio to tell me the version of the dll its using if i run it from the debug window, versus what's deployed on the target machine? I see the version number in the dll's property window. Is that all there is? There's no "cached" version visual studio uses?

Thank you.

Windows for business Windows Client for IT Pros User experience Other
Developer technologies .NET Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Michael Taylor 60,161 Reputation points
    2023-01-17T19:53:26.1833333+00:00

    It appears the issue is that your dependency has its own dependency that cannot be found. However the inner exception is a TypeInitializationException and that exception almost always has an inner exception. Please adjust your logging to print out the entire exception chain from the root exception all the way down until you run out of inner exceptions. For each exception log the type, message and stack trace. Personally I would recommend that you just build up a single event log entry that contains all the data.

    The version of the binary that will be used is generally the one that is the output directory of your application. Unless the assembly is strongly named AND you reference the strongly named version then the search path should retrieve from the app.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.