TargetInvocationException on Deployment

Posted on 2004-11-23
Last Modified: 2010-04-15
I have a weird issue that I'm trying to sort out and I'm wondering if anyone has any similar experiences to give me a lead.

A Windows app I developed runs fine locally, on my notebook (second computer) at home, and on my friend's machine apparently, but when I try to open the file at work to use it to perform an assigned task I get:

An unhandled exception of type
'System.Reflection.TargetInvocationException' occurred in mscorlib.dll

Additional information: Exception has been thrown by the target of an invocation.

I tried to see if I was including files on one machine that I wasn't on another and apparently they use the same stuff. Are there any circumstances where I'd get such an error on one machine and not another?
Question by:boulder_bum
    LVL 8

    Accepted Solution

    I believe this is an 'old' bug in the 1.0 Framework, but dunno if it occurs in 1.1 as well. This should be fixed when installing the latest service packs for the .NET framework. So my guess is the other machines have a certain Service pack installed, and this one machine hasn't.


    LVL 8

    Author Comment

    Good guess! Definately a useful bit of info.

    Unfortunately (or fortunately), all the machines look up-to-date on the patches.
    LVL 8

    Assisted Solution

    maybe this KB is any help
    LVL 4

    Assisted Solution

    boulder_bum, sometimes the above exception is caused by calling to a COM object. InnerException property holds the real exception with its description. So write to Event Log inner exception and see what was the problem. It was written in notepad and was not tested.

    try{ //your code
    catch( Exception e)
        string errorMessage = null;
        if ( e.InnerException == null )
          errorMessage = e.Message;
        else if ( e.InnerException.InnerException == null )
                  errorMessage = e.InnerException.Message;
               else errorMessage = e.InnerException.InnerException.Message;

        // Write errorMessage to Event Log

    LVL 8

    Author Comment

    I ended up e-mailing myself the entire solution and it turns out that my subclassed LicenseManager tried to reference a file that got created after a certain point in processing. The issue didn't show up before because I didn't license the class until a recent build.

    Why a FileNotFoundException wasn't thrown is a little puzzling to me, but at least it works now.

    Razzie and Jigit got the bigger points because I thought the answers were most likely to help, but I appreciate your effort, Tom, so props to you, too.
    LVL 8

    Expert Comment

    Sorry it wasn't THE answer you were looking for, but glad you got it all figured out anyway :)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Article by: Ivo
    Anonymous Types in C# by Ivo Stoykov Anonymous Types are useful when  we do not need to follow usual work-flow -- creating object of some type, assign some read-only values and then doing something with them. Instead we can encapsulate this read…
    This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now