locked
Exception has been thrown by the target of an invocation

    Question

  • Hi,

    (VS 2005, Beta 2)

    I get the error "Exception has been thrown by the target of an invocation" when I try to open any of the test windows using "Test|Windows|Test View" or any similar approach.

    I created a new solution a while ago and added some unit tests. Everything was working great, until now...

    Anybody have any suggestions?

    Thanks,
    Tor Langlo
    Monday, May 30, 2005 4:14 PM

Answers

  • Hello,

    I don't think deleting vsmdi and testrunconfig files would help.
    But yes, if you unload the solution, you should be able to bring up the windows. The problem comes in when your solution *is* the one that contains test projects which you want to execute tests on.
    In any case, if the suggestion or workaround does not work for you, please let me know. Thanks!

    Winnie
    Wednesday, June 15, 2005 11:39 PM

All replies

  • I assume this is not just for your solution, and is across all projects?
    Tuesday, May 31, 2005 5:55 PM
  • No, that's not correct. Today I created a new solution, and was able to add unit tests, and the tests show up in the Test View.

    My guess is something has gotten corrupted in the other solution. I've been doing a bit of renaming in it (namespaces, assemblies, directories), maybe this is the cause of the problem. I'll try to figure it out later.

    Tor.

    Wednesday, June 01, 2005 7:44 AM
  • I wouldn't worry that you have a corrupted solution or installation. This particular exception usually indicates a missing assembly reference. That is, at some point an assembly in team system referenced another assembly that wasn't in memory and could not be located.

    Did you install the Team Foundation client with VSTS? Does the problem you reported occur if you launch the IDE and don't load any solution whatsoever? Does the problem still repro if you load the original solution?

    Michael
    Tuesday, June 07, 2005 1:55 PM
  • I think you might be on to something here with the namespace/assembly renaming.  I do remember seeing at least one existing bug in Beta 2 related to errors caused by renamed assemblies and namespaces.  I've also experienced unhandled exception pain related to connecting to multiple separate TF server installations with Beta 2 because of a known cache bug (the first one you connect to would get cached, but in a way that would corrupt your ability to access a second distinct TF server installation).  The nastiness of this particular error message is that it doesn't give you much useful troubleshooting information other than the environment context you can remember from before it happened.  But I guess I should refrain from digressing into the tester version of Grumpy Old Programmer ( http://grumpyoldprogrammer.myblogsite.com )  :)

    If you do get some time to figure this out and get it isolated please keep the feedback coming with your repro steps, etc.  Your participation really is making a difference, links to these forum posts are added right there in the work item tracking system so it is a nice communications channel for us.

    ---
    Eric Jarvi
    http://blogs.msdn.com/ejarvi
    Tuesday, June 07, 2005 3:24 PM
  • Hi,

    If you are successfully creating and working with TV in a fresh project/solution, it sounds like something in the project or solution is broken.

    What we have experienced is this error when the solution file CPU-flavour references become corrupted (mostly from moving Solution files from old versions of whidbey).

    1: Open the .sln file in notepad
    2: Change All References to"AnyCPU" (note the missing space) to "Any CPU"
    3: Save
    4: Open the solution again

    Yours,
    Dominic

    Tuesday, June 07, 2005 5:17 PM
  • Unfortunately I had my harddisk crash on Friday, and the project(s) where I experienced the error were lost (at least temorarily until I know whether the disk can be rescued).

    I'll keep my eyes open, and report here if I can reproduce the problem.

    Thanks for all feedback,
    Tor.
    Tuesday, June 07, 2005 5:36 PM
  • I'm currently experiencing this problem.  I have not yet found the source of the problem or a work-around, but, in my case, the problem is related to a deployment project that was added as the ninth project in a solution which contains a web site and several other projects for the application.  If I remove the deployment project from the solution, the Manage and Execute Tests interface will appear and the list of tests will populate, but, when I add it back in, I either receive the error the original poster reported, or no error and an empty test list.  If I find the source of the problem, I will report back here.
    Wednesday, June 08, 2005 12:19 AM
  • I've been having the exact same problem. For me, the problem started when I added a Web Deployment Project into my solution.

    The solution has:
    Data Class libraries (in their own project)
    Business Class libraries (in their own project)
    Web Site
    Unit Test project
    Web Deployment project

    When I go to the "Manage and Execute Tests" menu item, I get "Exception has been thrown by the target of an invocation."

    Using SourceSafe to check "what changed" between the version that worked, and the one that didn't, the answer turned out to be the Web Deployment project.

    I can:
    1 - Launch VS.NET 2005 Beta 2
    2 - Click on "Manage and Execute Tests" and get the exception
    3 - Remove the Deployment project from the solution
    4 - Click on "Manage and Execute Tests" and have it work.
    (No restarting of VS.NET 2005 needed in the above 4 steps).

    I did try reporoducing this in a new solution, but was unable to get a similar failure.

    --
    Chris Mullins
    Wednesday, June 08, 2005 8:59 PM
  • If a "Web Setup Project" Deployment project exists within your solution, the "Manage and Execute Tests" feature will not work properly.  I will submit a bug report after posting this message.

    Here are the steps to reproduce the problem:


    1. Start Visual Studio 2005 Beta 2.

    2. Create a new Visual Basic Windows Application Project, allowing Visual Studio to create a solution for the project at creation time.  It is not necessary to add the project or solution to source control.

    3. Close the default form opened after the project has been created.

    4. Add a new "Test Project" project to the solution (in the Add New Project Window, select "Test Projects", then "Test Documents", then "Test Project".)

    5. Close the two default test project windows.

    6. Do a "Save All".

    7. Close the solution.

    8. Open the solution.

    9. Select "Manage and Execute Tests" from the Test menu. 

    10. In the Test Manager window, observe the three default test list options in the upper-left pane ("Lists of Tests", Tests Not in a List" and "All Loaded Tests")

    11. In the Test Manager window, click "Tests Not in a List" and observe the presence of the two default entries in main content pane of the Test Manager window, "manualtest1" and "TestMethod1".

    12. In the Test Manager window, click "All Loaded Tests" and observe the presence of the two default entries in main content pane of the Test Manager window, "manualtest1" and "TestMethod1".

    13. Close the Test Manager Window.

    14. Add a new "Web Setup Project" project to the solution (in the Add New Project Window, select "Other Project Types", then "Setup and Deployment", then "Web Setup Project".)

    15. Close the default "File System (ProjectName)" window.

    16. Do a "Save All".

    17. Close the solution.

    18. Open the solution.

    19. Select "Manage and Execute Tests" from the Test menu. 

    20. You will either receive the "Exception has been thrown by the target of an invocation" error, or you will see the Test Manager window.

    21. If you see the Test Manager window, continue with the following steps.

    22. In the Test Manager window, note the absence of the three default test list options ("Lists of Tests", Tests Not in a List" and "All Loaded Tests"), in the upper-left pane of the Test Manager window.

    23. In the Test Manager window, note the absence of the two previously visible default tests, "manualtest1" and "TestMethod1".

    24. Do a "Save All".

    25. Close the solution.

    26. Open the solution.

    27. Remove the "Web Setup Project" Deployment Project from the solution.

    28. Do a "Save All".

    29. Close the solution.

    30. Open the solution.

    31. Select "Manage and Execute Tests" from the Test menu. 

    32. In the Test Manager window, observe the three default test list options in the upper-left pane ("Lists of Tests", Tests Not in a List" and "All Loaded Tests")

    33. In the Test Manager window, click "Tests Not in a List" and observe the presence of the two default entries in main content pane of the Test Manager window, "manualtest1" and "TestMethod1".

    34. In the Test Manager window, click "All Loaded Tests" and observe the presence of the two default entries in main content pane of the Test Manager window, "manualtest1" and "TestMethod1".

    Thursday, June 09, 2005 7:00 PM
  • I've reported this as a bug, and it is currently being reviewed.

    The bug ID is FDBK29360.

    Bug URL:

    http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=25c7ff73-2478-46d3-8c78-ce6b644a2a03
    Thursday, June 09, 2005 7:39 PM
  • Thank you very much for reporting the bug.
    I have checked that this bug has already been fixed for the RTM version of the product.
    The only known workaround is to remove the setup project for the solution. Sorry for the inconvenience caused.

    Thanks!
    Winnie
    Thursday, June 09, 2005 8:27 PM
  • I had a similar problem with a Sql Server Integration Services Project in my solution..
    by Unloading the solution, i could again Manage and View the Tests.
    I had also deleted the .vsmdi and .testrunconfig files from the solution... although i'm not sure if it was needed, so vs.net would generate new ones (I had to delete them via explorer, as vs.net wouldn't let me)
    Wednesday, June 15, 2005 4:09 AM
  • Hello,

    I don't think deleting vsmdi and testrunconfig files would help.
    But yes, if you unload the solution, you should be able to bring up the windows. The problem comes in when your solution *is* the one that contains test projects which you want to execute tests on.
    In any case, if the suggestion or workaround does not work for you, please let me know. Thanks!

    Winnie
    Wednesday, June 15, 2005 11:39 PM
  • ok, well. it seems that all i needed to do is leave it along for 30minutes and it worked. No joke. I think my computer is evoluting. =D Maybe it will make my code for me!! =)
    Tuesday, June 28, 2005 5:08 PM
  • yes deleting the .vsmdi and testrunconfig doesn't do anything..
    i encoutnered the error once again when i added a Deployment project (.msi).
     it seems that the error in vs.net is related to the test manager/system trying to parse/read/analyse certain types of Projects.
    when i removed the deployment project from the solution, it all worked again
    Friday, July 01, 2005 5:25 AM
  • for what its worth, heres my 2 cents:

    i had this same error a bit after i added a setup project to my solution. i didnt fix it by removing it, instead i found out that the problem was something else:
    before i got the error, i propertied the setup project release folder to be shared to my home network so i could install it on the other pc. seems that un-sharing this folder fixed the error.

    thanks for all the ones who replied to this post, somewhere in page 1 i remember i got the idea of unsharing from one of the posts which i cant remember right now.

    enjoy

    Monday, April 17, 2006 11:17 PM
  • Hi All,

     

      In my UI Layer I am raising the Exception Divisible by Zero.

      In Catch block of UI Layer I am calling the Business layer function to write this exception into Event Viewer

      After the Exception writes into the Event viewer the control come back to UI Layer of Catch block.

      When I am getting the error like “Exception has been thrown by the target of an invocation.”

     

      If you know the solution for this problem, please reply to this mail.

     

      I am using   

     .Net 2.0, Application Block 2.0 and XP Professional

     

    See the Following Code

     

    Business Layer

     

            public interface ICommonFunctions

        {

          void LogErrInToFile(Exception ex);

        }

     

        public class CommonFunctions : MarshalByRefObject, ICommonFunctions

        {

            public bool LogErrInToFile(Exception ex)

            {

     

                bool boolError = ExceptionPolicy.HandleException(ex, "ExceptionPolicy");          

            }

        }

     

     UI Layer

    try

                {

                    int i = 1;

                    int j = 0;

              int k = i / j;

                }

                catch (Exception ex)

                {

                   bool boolError =  objCF.LogErrInToFile(ex); //Error occurs after the control comes from Business layer.

                }

                finally

                {

                }

     

    Error

    System.Reflection.TargetInvocationException was unhandled

      Message="Exception has been thrown by the target of an invocation."

      Source="mscorlib"

      StackTrace:

        Server stack trace:

           at System.RuntimeMethodHandle._SerializationInvoke(Object target, SignatureStruct& declaringTypeSig, SerializationInfo info, StreamingContext context)

           at System.RuntimeMethodHandle.SerializationInvoke(Object target, SignatureStruct declaringTypeSig, SerializationInfo info, StreamingContext context)

           at System.Reflection.RuntimeConstructorInfo.SerializationInvoke(Object target, SerializationInfo info, StreamingContext context)

           at System.Runtime.Serialization.ObjectManager.CompleteISerializableObject(Object obj, SerializationInfo info, StreamingContext context)

           at System.Runtime.Serialization.ObjectManager.FixupSpecialObject(ObjectHolder holder)

           at System.Runtime.Serialization.ObjectManager.DoFixups()

           at System.Runtime.Serialization.Formatters.Soap.ObjectReader.Deserialize(HeaderHandler handler, ISerParser serParser)

           at System.Runtime.Serialization.Formatters.Soap.SoapFormatter.Deserialize(Stream serializationStream, HeaderHandler handler)

           at System.Runtime.Remoting.Channels.CoreChannel.DeserializeSoapResponseMessage(Stream inputStream, IMessage requestMsg, Header[] h, Boolean bStrictBinding)

           at System.Runtime.Remoting.Channels.SoapClientFormatterSink.DeserializeMessage(IMethodCallMessage mcm, ITransportHeaders headers, Stream stream)

           at System.Runtime.Remoting.Channels.SoapClientFormatterSink.SyncProcessMessage(IMessage msg)

        Exception rethrown at [0]:

           at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)

           at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)

           at Thames.OSS.Interfaces.ICommonFunctions.LogErrInToFile(Exception ex)

           at OSSThickClientProject.ProfileManagement.profileManagement_Load(Object sender, EventArgs e) in D:\GISADS3\OSSThickClientProject\ProfileManagement.cs:line 63

           at System.Windows.Forms.Form.OnLoad(EventArgs e)

           at System.Windows.Forms.Form.OnCreateControl()

           at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)

           at System.Windows.Forms.Control.CreateControl()

           at System.Windows.Forms.Control.WmShowWindow(Message& m)

           at System.Windows.Forms.Control.WndProc(Message& m)

           at System.Windows.Forms.ScrollableControl.WndProc(Message& m)

           at System.Windows.Forms.ContainerControl.WndProc(Message& m)

           at System.Windows.Forms.Form.WmShowWindow(Message& m)

           at System.Windows.Forms.Form.WndProc(Message& m)

           at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)

           at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)

           at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

           at System.Windows.Forms.UnsafeNativeMethods.SendMessage(HandleRef hWnd, Int32 msg, Int32 wParam, Int32 lParam)

           at System.Windows.Forms.Form.SetVisibleCore(Boolean value)

           at System.Windows.Forms.Control.set_Visible(Boolean value)

           at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)

           at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)

           at System.Windows.Forms.Application.Run(Form mainForm)

           at OSSThickClientProject.Program.Main() in D:\GISADS3\OSSThickClientProject\Program.cs:line 20

           at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)

           at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)

           at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()

           at System.Threading.ThreadHelper.ThreadStart_Context(Object state)

           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

           at System.Threading.ThreadHelper.ThreadStart()

     Thanks in advance.

    Regards

    Rajaram.

    Friday, July 14, 2006 5:05 AM
  • Thnx buddy, I was facing the same problem  while inovation of objects by using reflection
     and i found de correct solution.
    Monday, July 09, 2007 9:32 AM
  • Hi guys,

    i'm having the same problem when adding an access db connection in server explorer. any ideas on this?

    thanks,

    dave
    Friday, September 14, 2007 1:38 AM
  • Hi

     

    I got the same error "Exception has been thrown by the target of an invocation" when I run my solution under windows 2000. But when I run this solution on a pc running windows xp work fine.

     

    Actually my VB6 COM object have three parameter and one of them is long some how it doesn't work in windows 2000. After spending time on it I passed all three parameters as string and it worked Smile .

    Here is my code that now worked on both 2000 and XP.

     

    windows 2000 machine has only .Net framework 1.1

    XP machine has .Net framework 1.1 and 2.0 but I make this solution in .Net 1.1

     

    Dim lStatus As Long

    Dim lTaskKey As Long

    Dim objParam As Object

    ReDim objParam(2)

     

    lTaskKey= 15694

    objParam(0) = lTaskKey.ToString()     ' When I pass ItaskKey as long it gives an error on windows 2000

    objParam(1) = "XYZ"

    objParam(2) = "Server2"

     

    ' Late binding way

    Dim objType As Type

    Dim objObject As Object

     

    objType = Type.GetTypeFromProgID("HR.Task") ' HR.Task is a VB6 COM

    objObject = Activator.CreateInstance(objType)

     

    lStatus = objType.InvokeMember("GetStatus", System.Reflection.BindingFlags.InvokeMethod, System.Type.DefaultBinder, objObject, objParam)

     

    I hope this will help to some one.

    thx

     

    Saturday, October 20, 2007 5:39 AM
  • I'm having the sam problem

     

    Im using VB in VS 2005.

     

    The code is:

     

    'This event is fired on the background thread

    mobjQueueReader = New STARWorkFileListener.cWrkFleListener

    AddHandler mobjQueueReader.UpdateThreads, AddressOf Me.UpdateTextBox

    mobjQueueReader.StartListening(sCN)

     

    It compiles with no problem but errs on the Addhandler the full message is:

     

    System.Reflection.TargetInvocationException was unhandled by user code
      Message="Exception has been thrown by the target of an invocation."
      Source="mscorlib"
      StackTrace:
           at System.RuntimeMethodHandle._SerializationInvoke(Object target, SignatureStruct& declaringTypeSig, SerializationInfo info, StreamingContext context)
           at System.RuntimeMethodHandle.SerializationInvoke(Object target, SignatureStruct declaringTypeSig, SerializationInfo info, StreamingContext context)
           at System.Reflection.RuntimeConstructorInfo.SerializationInvoke(Object target, SerializationInfo info, StreamingContext context)
           at System.Runtime.Serialization.ObjectManager.CompleteISerializableObject(Object obj, SerializationInfo info, StreamingContext context)
           at System.Runtime.Serialization.ObjectManager.FixupSpecialObject(ObjectHolder holder)
           at System.Runtime.Serialization.ObjectManager.DoFixups()
           at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
           at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
           at System.EnterpriseServices.ComponentSerializer.UnmarshalFromBuffer(Byte[] b, Object tp)
           at System.EnterpriseServices.ComponentServices.ConvertToMessage(String s, Object tp)
           at System.EnterpriseServices.ServicedComponent.RemoteDispatchHelper(String s, Boolean& failed)
           at System.EnterpriseServices.ServicedComponent.System.EnterpriseServices.IRemoteDispatch.RemoteDispatchNotAutoDone(String s)
           at System.EnterpriseServices.IRemoteDispatch.RemoteDispatchNotAutoDone(String s)
           at System.EnterpriseServices.RemoteServicedComponentProxy.Invoke(IMessage reqMsg)
           at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
           at System.Object.FieldSetter(String typeName, String fieldName, Object val)
           at STARWorkFileListener.frmWrkFileListener.Worker_DoWork(Object sender, DoWorkEventArgs e) in C:\Galaxy\Services\File Listener\STARWorkFileListener\frmWrkFileListener.vb:line 359
           at System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e)
           at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument)

     

    Any Ideas what I may have missed?

     

    Thanks

    Tuesday, December 18, 2007 6:36 PM

  • I am using VS2008 SP1 on x86 Vista

    If you have any help for this problem, please email to reprisethelung@live.com or just post on this discussion. Thank you very much for any time anybody puts into it.



     I Have been having the same problem, but only after I did the following:

    1. Installed VS2008 SP1 (.NET 3.5)

    2. Installed the Silverlight 2.0 SDK

    3. Then I created a VB.sln (for Silverlight)and played around with a Silverlight 2.0 project in VB/xaml/html/javascript/aspx and 
        everything was working great.
        
    4. Then I tried to create a new .sln for a new C# Silverlight project, but got a message saying "C# compiler could not be created"
        And was not be able to creat any C# .sln, including a C# Console Application.

    5. Upon encoutering that problem, I did some searching and discoverd "Devenv.exe"
        After running that, used "devenv.exe /ResetSkipPkgs", and then I was able to create all the types of C# .sln's.

    6. I only get that message (posted below) in the design view while developing Silverlight apps in either C# or VB.
        However, by clicking the 'Click here to reload designer', with one or two clicks, it usually goes away.

     
    The only reason I post this is because the messages are scary, and it bugs me that something horribly wrong could be going on with Visual Studio. The software costed soooo much, and I care about the health of it. I reallize I am at fault for not researching "devenv.exe /ResetSkipPkgs" before entering it or trying to find all solutions to my compiler problem.



    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - THE MESSAGE THAT POPS UP IN DESIGN VIEW - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



    An unhandled exeption has occured:

    Click here to reload the designer

    Details:


    Exception has been thrown by the target of an invocation.

    at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at MS.Internal.Package.MetadataLoader.InitializeProfileMetadata(RegistryKey registryRoot, String profile, LogCallback logger) at MS.Internal.Designer.VSIsolatedDesigner.VSIsolatedDesignerFactory.CreateDesigner(DesignerContext context) at MS.Internal.Host.Isolation.IsolatedDesigner.BootstrapProxy.CreateDesigner(IsolatedDesignerFactory factory, IDesignerContextProtocol contextProtocol) at MS.Internal.Host.Isolation.IsolatedDesigner.BootstrapProxy.CreateDesigner(IsolatedDesignerFactory factory, IDesignerContextProtocol contextProtocol) at MS.Internal.Host.Isolation.IsolatedDesigner.Load() at MS.Internal.Designer.DesignerPane.LoadDesignerView()

    Could not load type 'System.Windows.Controls.WebBrowser' from assembly 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

    at Microsoft.Windows.Design.Metadata.DeveloperMetadata.DeveloperMetadataBuilder.AddWebBrowserAttributes() at Microsoft.Windows.Design.Metadata.DeveloperMetadata.DeveloperMetadataBuilder..ctor() at Microsoft.Windows.Design.Metadata.DeveloperMetadata.get_CustomAttributes() at Microsoft.Windows.Design.Metadata.DeveloperMetadata.Initialize()

    Tuesday, October 21, 2008 10:03 AM
  • I have the same issue on message box invocation:

    if (MessageBox.Show("Start simulation ?", "Title",
              MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)

    {
    backgroundWorker1.RunWorkerAsync();
    }
    else
    {
    return;
    }

    Removing this invocation fixes the problem for me.
    Tuesday, February 24, 2009 2:02 PM
  • I ran into this problem in a windows app solution, one of my custom components read to a DB in the constructor after initialization. Solution didn't like that, so I created a public method and called that from the parent form after it loaded.

    Just another solution to add to the bunch.
    Wednesday, April 08, 2009 6:00 PM
  • I was also encoutering the "Exception has been thrown by the target of an invocation" error for no apparent reason in Visual Studio 2008.

    The solution is:

    1.       Close all the instances of Visual Studio

    2.       Open a VS (Without opening the solution).

    3.       Go to Test -> Windows -> Test Results.

    4.       Now open the solution and vsmdi.

    5.       Tests would run as usual J

    • Proposed as answer by BirukSolomon Wednesday, October 28, 2009 7:46 PM
    Friday, June 05, 2009 8:43 AM
  • I was also encoutering the "Exception has been thrown by the target of an invocation" error for no apparent reason in Visual Studio 2008.

    The solution is:

    1.       Close all the instances of Visual Studio

    2.       Open a VS (Without opening the solution).

    3.       Go to Test -> Windows -> Test Results.

    4.       Now open the solution and vsmdi.

    5.       Tests would run as usual J


    This worked brilliantly, thank you.

    At the moment I was writing new unit tests in a fresh Solution while TFS was down, this did the trick.
    Thursday, June 18, 2009 8:06 PM
  • From the application side I was installing an asp application that I know works properly in other enviornments but I was getting the same error. The fix ended up being a repair to .net framework 3.5.
    Wednesday, August 19, 2009 7:36 PM
  • I was also encoutering the "Exception has been thrown by the target of an invocation" error for no apparent reason in Visual Studio 2008.

    The solution is:

    1.       Close all the instances of Visual Studio

    2.       Open a VS (Without opening the solution).

    3.       Go to Test -> Windows -> Test Results.

    4.       Now open the solution and vsmdi.

    5.       Tests would run as usual J


    Great .. thank you
    Thursday, January 28, 2010 10:33 AM
  • It's a "Five Step Program" that really works!  Brilliant solution!  Looking forward to a fix because that error message is pretty cryptic.

    Thursday, May 06, 2010 8:28 PM
  • In case you are using TFS (team foundation server), for some reason your solution went offline and when you make it go online again it will fix the issue.

    1) Open your solution
    2) Right Click the solution and click "Go Online"
    3) Re-run the test. By now that error message must have gone away

    • Proposed as answer by masharm Saturday, July 17, 2010 1:05 AM
    Saturday, July 17, 2010 1:05 AM
  • I have the same problem on VS2008 SP1.

    After disconnect/reconnect solution from TFS all work correctly.

    Saturday, August 21, 2010 5:52 PM
  • the solution of this problem comes from a beug microsoft for, use the unit testing tool for Visual Studio 2008,

    will require a support request for the hotfix hostfix, this fix is unfortunately protected by the laws of use here is the link to request

    http://support.microsoft.com/?kbid=980216
     The software is VS90SP1-KB980216-x86.exe

    Monday, October 18, 2010 3:44 PM
  • If you have .edmx file in your project

    then please change the properties

     

      1. Right click on .edmx file select properties

      2. Please Change Build Action: Entity Deploy

     F5 to see  whether it's fixed

     

    Thanks

    Wednesday, September 21, 2011 7:01 AM
  • Hi, have you solved the problem?  can you tell me how , i'm so freak out of it now.
    Tuesday, November 15, 2011 3:04 AM
  • rajaram, Have you ever found the solution to your error? I have the same problem!!!!


    fffz
    Thursday, February 02, 2012 11:24 PM
  • @sanket ...

    Test -> Windows -> Test Results. still gives

    "Exception has been thrown by the target of an invocation" :(

    Monday, February 13, 2012 1:23 PM
  • Has anyone found a solution to this problem. I have the same issue

    When I try to save the webtest I get the exception "Exception thrown by the target of invocation". The regular website works properly I m facing issue with the webtest only.

    I m using Windows Vista - VS2010 Premium


    Thursday, March 15, 2012 6:24 AM
  • Hi shreyamalani can you please check following checkpoint in your application..

    1)Check for TFS connectivity.You may not have access to TFS projects or TFS is not connected.

    2)Check if you are inheriting any class with out service namesapce(.).

    3)Check your are trying to refer a method with out instantani.. it.

    Monday, September 17, 2012 8:23 AM