1

I have an issue where I am receiving the error, "Exception has been thrown by the target of an invocation. I have the new keyword in place. I made sure the ReportsData_Employee.COATSEndAssignmentDataTable existed.

    Imports System.Windows.Forms
    Imports Advance.Extensions.Reporting
    Imports CrystalDecisions.Shared
    Imports Advance.Common.Reporting
    Imports System.IO

    Public Class Activity_EndAssignmentTool
        ReadOnly _dt As New DataTable
        Dim _dts As New DataTable
        Dim _bldts As New DataTable
        Dim _xml_file_name_creation As String
    '// This is the line that is causing the error ============
        ReadOnly _xml_datatable As ReportsData_Employee.COATSEndAssignmentDataTable = New ReportsData_Employee.COATSEndAssignmentDataTable()
    '//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

   ====================================================================================== 

   System.Reflection.TargetInvocationException was caught
   HResult=-2146232828
   Message=Exception has been thrown by the target of an invocation.
   Source=mscorlib
   StackTrace:
   at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly,        Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
   at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
   at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
   at System.Activator.CreateInstance(Type type, Boolean nonPublic)
   at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark)
   at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
   at System.Reflection.Assembly.CreateInstance(String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
   at System.Reflection.Assembly.CreateInstance(String typeName)
   at Advance.Extensions.Activities.Activity_Form.GetActivityForm(String className) in C:\Users\JJanssen\Documents\Visual Studio 2010\Projects\Legacy\Advance Extensions\advance.extensions.activities\Forms\Activity_Form.vb:line 126
   at Advance.Extensions.Activities.Activity_Form.SetActivityClass() in C:\Users\JJanssen\Documents\Visual Studio 2010\Projects\Legacy\Advance Extensions\advance.extensions.activities\Forms\Activity_Form.vb:line 60
   InnerException: System.NullReferenceException
   HResult=-2147467261
   Message=Object reference not set to an instance of an object.
   Source=Advance.Extensions.Activities
   StackTrace:
   at Advance.Extensions.Activities.Activity_EndAssignmentTool.InitializeComponent() in C:\Users\JJanssen\Documents\Visual Studio 2010\Projects\Legacy\Advance Extensions\advance.extensions.activities\Activity_Forms\Activity_EndAssignmentTool.Designer.vb:line 479
   at Advance.Extensions.Activities.Activity_EndAssignmentTool..ctor() in C:\Users\JJanssen\Documents\Visual Studio 2010\Projects\Legacy\Advance Extensions\advance.extensions.activities\Activity_Forms\Activity_EndAssignmentTool.vb:line 12
   InnerException: 

Can someone name some other reasons why I could be getting this error? I have looked at multiple links but a lot of the answers don't apply in my situation.

"Exception has been thrown by the target of an invocation" error (mscorlib)

FYI I have tried ReadOnly _xml_datatable as New ReportsData_Employee.COATSEndASsignmentDataTable() and there was still an issue.

Any help is appreciated. Let me know if there is any other information you need.

Thanks.

Community
  • 1
  • 1
John Janssen
  • 293
  • 2
  • 12
  • 30
  • I am having this issue when I start the Microsoft SQL Server Management Studio. – Marcello Miorelli Sep 22 '14 at 09:58
  • 1
    @marcelomiorelli I didn't have the issue with ssms, but I found this forum that might help you. https://connect.microsoft.com/SQLServer/feedback/details/668421/denali-exception-has-been-thrown-by-the-target-of-an-invocation-during-setup – John Janssen Sep 22 '14 at 13:13

1 Answers1

1

You haven't initialized object properly. Here...

ReadOnly _xml_datatable As ReportsData_Employee.COATSEndAssignmentDataTable = New ReportsData_Employee.COATSEndAssignmentDataTable()

Should be

Private ReadOnly _xml_datatable As New ReportsData_Employee.COATSEndAssignmentDataTable()

Your real issue is

 InnerException: System.NullReferenceException
 HResult=-2147467261
 Message=Object reference not set to an instance of an object.
 Source=Advance.Extensions.Activities

You need to look into constructor of COATSEndAssignmentDataTable. you have NullReferenceException in there. These two lines tell you exact location

at Advance.Extensions.Activities.Activity_EndAssignmentTool.InitializeComponent()
in C:\Users\JJanssen\Documents\Visual Studio 2010\Projects\Legacy\Advance Extensions\advance.extensions.activities\Activity_Forms\Activity_EndAssignmentTool.Designer.vb:line 479

at Advance.Extensions.Activities.Activity_EndAssignmentTool..ctor() 
in C:\Users\JJanssen\Documents\Visual Studio 2010\Projects\Legacy\Advance Extensions\advance.extensions.activities\Activity_Forms\Activity_EndAssignmentTool.vb:line 12
T.S.
  • 18,195
  • 11
  • 58
  • 78
  • Whether I put Private or not, this change still does not work properly. I still receive the same error. – John Janssen Jun 02 '14 at 19:27
  • `Private ReadOnly _xml_datatable As New ReportsData_Employee.COATSEndAssignmentDataTable()` still produces the same error. – John Janssen Jun 02 '14 at 19:27
  • @JohnJanssen You need to look into constructor of `COATSEndAssignmentDataTable`. you have `NullReferenceException` in there – T.S. Jun 02 '14 at 19:32
  • Very interesting. A `.EndInit()` in my designer that has been there for many years, threw the exception. Thank you for analyzing the stacktrace. – John Janssen Jun 02 '14 at 19:43
  • @JohnJanssen No problem. I hope you resolve it soon. – T.S. Jun 02 '14 at 19:46