I have a website developed in ASP.Net 2.0 that is throwing the error
"Exception has been thrown by the target of an invocation"
in the production environment. It was not throwing this error in development.
The source is ‘mscorlib’, and the stack trace says the error at
System.RuntimeMethodHandle._InvokeMethodFast.
The only thing I’ve changed since my last upload to production is that I’ve started using Membership controls (Login, LoginView), and have added a few more stored procedures and tables, etc. The membership depends upon a custom provider I’ve written.
Anybody have a clue why this could be happening?
Joel Coehoorn
392k111 gold badges561 silver badges788 bronze badges
asked Mar 15, 2009 at 16:47
Donnie ThomasDonnie Thomas
3,8398 gold badges47 silver badges69 bronze badges
2
I’d suggest checking for an inner exception. If there isn’t one, check your logs for the exception that occurred immediately prior to this one.
This isn’t a web-specific exception, I’ve also encountered it in desktop-app development. In short, what’s happening is that the thread receiving this exception is running some asynchronous code (via Invoke(), e.g.) and that code that’s being run asynchronously is exploding with an exception. This target invocation exception is the aftermath of that failure.
If you haven’t already, place some sort of exception logging wrapper around the asynchronous callbacks that are being invoked when you trigger this error. Event handlers, for instance. That ought to help you track down the problem.
Good luck!
answered Mar 15, 2009 at 16:51
4
This can happen when invoking a method that doesn’t exist.
Brian Webster
29.7k48 gold badges150 silver badges224 bronze badges
answered Aug 4, 2010 at 4:06
Casey BurnsCasey Burns
1,19311 silver badges15 bronze badges
2
I know its kind of odd but I experienced this error for a c# application and finally I found out the problem is the Icon of the form! when I changed it everything just worked fine.
I should say that I had this error just in XP not in 7 or 8 .
answered Mar 9, 2013 at 7:50
Encounter the same error when tried to connect to SQLServer2017 through Management Studio 2014
The reason was backward compatibility
So I just downloaded the Management Studio 2017 and tried to connect to SQLServer2017.
Problem Solve!!
answered Sep 13, 2019 at 7:04
KmsKms
9572 gold badges9 silver badges27 bronze badges
' Get the your application's application domain.
Dim currentDomain As AppDomain = AppDomain.CurrentDomain
' Define a handler for unhandled exceptions.
AddHandler currentDomain.UnhandledException, AddressOf MYExHandler
' Define a handler for unhandled exceptions for threads behind forms.
AddHandler Application.ThreadException, AddressOf MYThreadHandler
Private Sub MYExnHandler(ByVal sender As Object, _
ByVal e As UnhandledExceptionEventArgs)
Dim EX As Exception
EX = e.ExceptionObject
Console.WriteLine(EX.StackTrace)
End Sub
Private Sub MYThreadHandler(ByVal sender As Object, _
ByVal e As Threading.ThreadExceptionEventArgs)
Console.WriteLine(e.Exception.StackTrace)
End Sub
' This code will throw an exception and will be caught.
Dim X as Integer = 5
X = X / 0 'throws exception will be caught by subs below
answered Jun 25, 2010 at 5:23
1
This error occurs to me due to I have not set my Project as StartUp Project
When I set my current project to Set As Start-Up Project then it gone.
answered Apr 2, 2019 at 8:24
I just had this issue from a namespace mismatch. My XAML file was getting ported over and it had a different namespace from that in the code behind file.
answered Jan 20, 2016 at 20:55
Greg SipesGreg Sipes
6836 silver badges16 bronze badges
This is may have 2 reasons
1.I found the connection string error in my web.config file
i had changed the connection string and its working.
- Connection string is proper then check with the control panel>services>
SQL Server Browser > start or not
answered Jan 24, 2017 at 6:09
Got same error, solved changing target platform from «Mixed Platforms» to «Any CPU»
answered Aug 6, 2018 at 21:19
In my case, this happened due to choosing the option to publish as a single file in VS (.NET 5 console app), once I changed it to publish normally the exception was gone.
answered Mar 2, 2021 at 9:10
MeshalMeshal
32 silver badges3 bronze badges
I got this error after I tried to add a new controller in the Controller folder but the connection string was placed inside the entityFramework tag in Web.config file.
answered Apr 2, 2021 at 23:01
CSharp4etoCSharp4eto
1371 silver badge6 bronze badges
For me, it happens when there is an internal call to another server and that server is not answering in a logical time or the configuration to call it is wrong. I fixed the problem of connecting to another server, then I received the correct data from that server and the function that was responsible for calling that server is working properly then I do not receive that error.
Ajay2707
5,6686 gold badges40 silver badges58 bronze badges
answered Apr 29, 2021 at 14:41
Beny SadBeny Sad
2803 silver badges14 bronze badges
I edited the validation field, the error was resolved.
builder.Property(x => x.Name)**.UseIdentityColumn()**.HasMaxLength(200);
builder.Property(x => x.Name)**.IsRequired()**.HasMaxLength(200);
answered Mar 13, 2022 at 20:11
my problem was that i didnt put the connection string in the right place in the appsettings.json it was inside IIS Express object then i moved it inside profiles object it didnt work as well the i fixed the problem by putting it inside the appsettings.json { here }
answered May 12, 2022 at 7:23
1
In my case I just update Oracle.ManagedDataAccess.Core package from 2.19.60 to 3.21.61
answered Jul 13, 2022 at 11:28
ConsuleConsule
80910 silver badges12 bronze badges
I had the same problem.
I was trying to create a report from C# and it wasn’t checking if the field is empty or whitespace.
I add Exception.
answered Dec 23, 2022 at 11:37
When debugging and no InnerException found it can be handy to hit F5 (continue) until it hits another Exception. Or if it drops out entirely you can then check the Output window for more details.
answered Jan 18 at 12:11
DevDaveDevDave
6,56012 gold badges64 silver badges98 bronze badges
This article applies to Microsoft Dynamics AX for all regions.
Symptoms
Assume that you create a purchase order for a fixed asset in Microsoft Dynamics AX 2012. When you try to invoice the purchase order, you receive the following error message:
Exception has been thrown by the target of an invocation.
This problem occurs when you are running the system in CIL.
Resolution
Hotfix information
A supported hotfix is available from Microsoft. There is a «Hotfix download available» section at the top of this Knowledge Base article. If you are encountering an issue downloading, installing this hotfix, or have other technical support questions, contact your partner or, if enrolled in a support plan directly with Microsoft, you can contact technical support for Microsoft Dynamics and create a new support request. To do this, visit the following Microsoft website:
https://mbs.microsoft.com/support/newstart.aspx You can also contact technical support for Microsoft Dynamics by phone using these links for country specific phone numbers. To do this, visit one of the following Microsoft websites:
Partners
https://mbs.microsoft.com/partnersource/support/Customers
Installation information
If you have customizations for one or more of the methods or the tables that are affected by this hotfix, you must follow these steps:
-
Review the changes that are documented in the .xpo file.
-
Apply these changes in a test environment before you apply the hotfix in a production environment.
For more information about how to install this hotfix, click the following article number to view the article in the Microsoft Knowledge Base:
893082 How to install a Microsoft Dynamics AX hotfix
Prerequisites
You must have Microsoft Dynamics AX 2012 installed to apply this hotfix.
Restart requirement
You must restart the Application Object Server (AOS) service after you apply the hotfix.
File information
The global version of this hotfix has the file attributes (or later file attributes) that are listed in the following table. The dates and times for these files are listed in Coordinated Universal Time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time item in Control Panel.
|
File name |
File version |
File size |
Date |
Time |
Platform |
|---|---|---|---|---|---|
|
Aximpactanalysis.exe |
Not applicable |
60,280 |
06-Nov-2011 |
11:16 |
x86 |
|
Axupdate.exe |
Not applicable |
60,264 |
06-Nov-2011 |
11:16 |
x86 |
|
Dynamicsax2012-kb2696116-foundation.axmodel |
6.0.1108.330 |
18,344 |
29-Mar-2012 |
08:36 |
Not applicable |
|
Dynamicsax2012-kb2696116-syplabels.axmodel |
6.0.1108.330 |
812,968 |
29-Mar-2012 |
08:36 |
Not applicable |
|
Axsetupsp.exe |
6.0.947.853 |
1,361,768 |
15-Jan-2012 |
16:00 |
x86 |
|
Axutillib.dll |
6.0.947.0 |
817,512 |
11-Jul-2011 |
01:48 |
x86 |
|
Microsoft.dynamics.servicing.operations.dll |
6.0.888.436 |
35,752 |
15-Jun-2011 |
10:40 |
x86 |
|
Axsetupsp.resources.dll |
6.0.947.491 |
382,848 |
06-Nov-2011 |
11:16 |
x86 |
|
Axsetupsp.resources.dll |
6.0.947.491 |
370,560 |
06-Nov-2011 |
11:16 |
x86 |
|
Axsetupsp.resources.dll |
6.0.947.491 |
374,656 |
06-Nov-2011 |
11:16 |
x86 |
|
Axsetupsp.resources.dll |
6.0.947.491 |
374,656 |
06-Nov-2011 |
11:16 |
x86 |
|
Axsetupsp.resources.dll |
6.0.947.491 |
370,560 |
06-Nov-2011 |
11:16 |
x86 |
|
Axsetupsp.resources.dll |
6.0.947.491 |
378,752 |
06-Nov-2011 |
11:16 |
x86 |
|
Axsetupsp.resources.dll |
6.0.947.491 |
370,560 |
06-Nov-2011 |
11:16 |
x86 |
|
Axsetupsp.resources.dll |
6.0.947.491 |
374,656 |
06-Nov-2011 |
11:16 |
x86 |
|
Axsetupsp.resources.dll |
6.0.947.491 |
370,560 |
06-Nov-2011 |
11:16 |
x86 |
|
Axsetupsp.resources.dll |
6.0.947.491 |
374,656 |
06-Nov-2011 |
11:16 |
x86 |
|
Axsetupsp.resources.dll |
6.0.947.491 |
370,560 |
06-Nov-2011 |
11:16 |
x86 |
|
Axsetupsp.resources.dll |
6.0.947.491 |
407,424 |
06-Nov-2011 |
11:16 |
x86 |
Status
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the «Applies to» section.
Note This is a «FAST PUBLISH» article created directly from within the Microsoft support organization. The information contained herein is provided as-is in response to emerging issues. As a result of the speed in making it available, the materials may include typographical errors and may be revised at any time without notice. See Terms of Use for other considerations.
Need more help?
I have a winforms application which was working fine. Recently i formatted my system and reinstalled VS 2008. From that time the application has stopped running.
When i run it through VS it gives error
«exception has been thrown by the target of an invocation.»
I went on to debug and found that in the this exception comes when from c# code using reflection the code tries to invoke a function from an assembly which is written in c++.
Updated 20-Sep-22 21:08pm
Eventually I solved this myself. It was just a matter of getting to the root of the problem.
Actually the cuase of this exception was another exception which occured inside the method being invoked.
So i went to look out for solution by searching the exception ex.innerexception .
From there i searched the stack trace of that exception to finnaly get to the root of the problem.
So anyone getting this error do look for the innerexception cause the real problem lies there.
Thanks,
Mateen
for the said error, we are talking about inner exception. How to get this inner exception?
running bat «${NUGET_HOME}/nuget.exe restore Dotsolution.sln from jenkins file and getting this error:
Error parsing solution file at D:JenkinsworkspaceDotsolution.sln: Exception has been thrown by the target of an invocation.
Disable the ajax for a moment (EnablePartialRendering=»false» on the scriptmanager).
we Got Exception aftr that delete EnablePartialRendering property.
Great said by Mateen Khan, you need to understand what is you controls default value..
eg i’m using combobox in silverlight and i was trying to bind its selected index
as a default its selected index was -1
but it was get nothing from the respective property …
I looked inside the inner exception and find out my solution
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)
Summary
When starting the RESTAPI.exe program, ?Exception has been thrown by the target of an invocation? error is displayed
Objective
Resolve ?Exception has been thrown by the target of an invocation? error when starting RestAPI.exe in ICM10 on-premise installation
Environment
Incentive Compensation Management version 10
Steps
After installing and making the basic configuration to RestAPI.exe.config file, double clicking on RESTAPI.exe file to start the program results in the following error:
Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> System.Net.HttpListenerException: The process cannot access the file because it is being used by another process
?? at System.Net.HttpListener.AddAllPrefixes()
?? at System.Net.HttpListener.Start()
?? at Microsoft.Owin.Host.HttpListener.OwinHttpListener.Start(HttpListener listener, Func`2 appFunc, IList`1 addresses, IDictionary`2 capabilities, Func`2 loggerFactory)
?? at Microsoft.Owin.Host.HttpListener.OwinServerFactory.Create(Func`2 app, IDictionary`2 properties)
?? — End of inner exception stack trace —
?? at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
?? at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
?? at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
?? at Microsoft.Owin.Hosting.ServerFactory.ServerFactoryAdapter.Create(IAppBuilder builder)
?? at Microsoft.Owin.Hosting.Engine.HostingEngine.Start(StartContext context)
?? at Microsoft.Owin.Hosting.Starter.HostingStarter.Start(StartOptions options)
?? at Varicent.RESTAPI.Program.Start(String[] args)
?? at Varicent.RESTAPI.Program.Main(String[] args)
This error usually occurs when RestAPI port is conflicting with another process that uses the same communication port. In most of the cases, this is the web server Apache, which is many time configured to use port 8080.
To solve this there are two ways:
1. Go to your Apache installation directory and then ‘conf‘ folder (e.g. C:Program Files (x86)Apache Software FoundationApache2.2conf) and open httpd.conf file.
2. Change the port number within the following line:
Listen 8080
to
Listen 8081
3. Save the file
4. Restart Apache web service
5. Restart RESTAPI.exe. The service is working now.
?
[{«Business Unit»:{«code»:»BU059″,»label»:»IBM Software w/o TPS»},»Product»:{«code»:»SSMKJE»,»label»:»IBM Incentive Compensation Management»},»Component»:»»,»Platform»:[{«code»:»PF025″,»label»:»Platform Independent»}],»Version»:»All Versions»,»Edition»:»»,»Line of Business»:{«code»:»LOB10″,»label»:»Data and AI»}}]
Some quick solutions if you don’t want to read the story:
- Check if package variables referenced in script task are correct
- Check if package variables are being set correctly outside of the script task
- Check if the script task’s references match up with the server’s framework
- My issue: check if you have permissions
Back to my story:
The other day, one of the packages I maintain broke in nearly every region it was deployed to. I’m thinking “Omg, why?” since this process has never failed in the years it has been implemented. So, I looked at the log to find the descriptive error message : “Exception has been thrown by the target of an invocation”:
I’m thinking, “Cool, I’ve seen this before, it should be easy“. So I go through the code to trace it to where it was bombing out, then I go through the routine of debugging the common issues:
- Check if package variables referenced in script task are correct – nope!
- Check if package variables are being set correctly outside of the script task – nope!
- Check if the script task’s references match up with the server’s framework – nope!
Nothing seemed to be off in the cases. Eventually, I assume that it has to be a security issue – because that seems to be the solution to everything for me. I run the process in a dev server to find that everything is fine. Now I’m like “Seriously?!“.
Frustrated, I end up wrapping the code in a try catch to print out the error and deploy:
Ah, I knew it! Unauthorized access:
Short story, I looked at previous versions of the directory to find the security had changed. I end up getting permissions added for the users, and ta da! Worked like a charm.
Lessons learned:
- Think outside the box. How the heck would someone think it’s a security issue from “…target of invocation”?
- Better error handling
- Don’t forget to rollback the changes you deployed to quickly find out what was going on since it’s not really good code and you could get in trouble for it
Hopefully that helps! Happy coding!
check
Best Answer
After installing Microsoft .NET Framework 4.7.2 for Windows 8.1, Windows RT 8.1, and Windows Server 2012 R2 (KB4054566) my entire server is operational again.
I can access SSMS and it also some other issues we had on the server.
Thank you very much for the help!
Was this post helpful?
thumb_up
thumb_down
View Best Answer in replies below
8 Replies
-
What version of SSMS? It could just need a repair or re-install or better yet just get the latest Opens a new window Opens a new window from Microsoft.
Was this post helpful?
thumb_up
thumb_down
-
Larry Shanahan wrote:
What version of SSMS? It could just need a repair or re-install or better yet just get the latest Opens a new window from Microsoft.
We are running SQL Server 2014, but I am not quite sure how to check SSMS without being able to start SSMS.
Also, as you might already have guessed, I am not exactly what you would call a SQL expert, how would I repair SSMS?
A side note, my server is located on a location with very bad internet connection (384 kbps down, 128 kbps up), so it makes it a bit difficult to make large downloads.
Was this post helpful?
thumb_up
thumb_down
-
peh wrote:
Larry Shanahan wrote:
What version of SSMS? It could just need a repair or re-install or better yet just get the latest Opens a new window from Microsoft.
We are running SQL Server 2014, but I am not quite sure how to check SSMS without being able to start SSMS.
Also, as you might already have guessed, I am not exactly what you would call a SQL expert, how would I repair SSMS?
A side note, my server is located on a location with very bad internet connection (384 kbps down, 128 kbps up), so it makes it a bit difficult to make large downloads.
One question: Are you running SSMS locally on your machine or are you using remote desktop and opening SSMS on the VM?
Okay, two: Did you confirm operation of the SQL Server instance on the VM after the upgrade?
If you go into Programs and Features and look for Microsoft SQL Server Management Studio, it should tell you the version. You may also be able to do a repair install from there (needs local admin rights). Right-click on SSMS and select repair if it gives you that option or uninstall if not. The installer should give you an option to do the repair.
Was this post helpful?
thumb_up
thumb_down
-
Larry Shanahan wrote:
One question: Are you running SSMS locally on your machine or are you using remote desktop and opening SSMS on the VM?
Okay, two: Did you confirm operation of the SQL Server instance on the VM after the upgrade?
If you go into Programs and Features and look for Microsoft SQL Server Management Studio, it should tell you the version. You may also be able to do a repair install from there (needs local admin rights). Right-click on SSMS and select repair if it gives you that option or uninstall if not. The installer should give you an option to do the repair.
I am connecting to the SSMS on the server, which is hosting the databases.
The databases are working after the upgrade. Only other issue we encountered were that the SQL Server service was Disabled.
When searching for Server Management Studio in the «Programs and Features» there are no records.
Was this post helpful?
thumb_up
thumb_down
-
Your best bet is a re-install of SSMS from your installation media (SSMS is a separate product now but I don’t remember when MS made the split).
You could download SSMS 17 and install that as well.
Was this post helpful?
thumb_up
thumb_down
-
Larry Shanahan wrote:
Your best bet is a re-install of SSMS from your installation media (SSMS is a separate product now but I don’t remember when MS made the split).
You could download SSMS 17 and install that as well.
I will try making a installation of SSMS, but we are also having some .NET issues on the server, so I will see if I can resolve them first.
Was this post helpful?
thumb_up
thumb_down
-
peh wrote:
Larry Shanahan wrote:
Your best bet is a re-install of SSMS from your installation media (SSMS is a separate product now but I don’t remember when MS made the split).
You could download SSMS 17 and install that as well.
I will try making a installation of SSMS, but we are also having some .NET issues on the server, so I will see if I can resolve them first.
Newer versions of SSMS (don’t remember exactly when MS did the switch over) are built on top of Visual Studio and require .NET, so that could easily be the source of the SSMS problem.
Was this post helpful?
thumb_up
thumb_down
-
After installing Microsoft .NET Framework 4.7.2 for Windows 8.1, Windows RT 8.1, and Windows Server 2012 R2 (KB4054566) my entire server is operational again.
I can access SSMS and it also some other issues we had on the server.
Thank you very much for the help!
Was this post helpful?
thumb_up
thumb_down









