• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA: Microsoft .NET Framework error

inddon

Member
Hello There,

I am getting a very strange error message all of a sudden. Never had this before (2 screen snapshots and error message listed below).

It says in the message to add the below to machine.config
I made a backup copy and applied the changes, it errors out. I restored the original file.

Code:
<configuration>
  <system.windows.forms jitDebugging="true" />
</configuration>


Has anyone come across the below message. Appreciate your help

Thanks & regards,
Don



First Error:
See the end of this message for details on invoking

just-in-time (JIT) debugging instead of this dialog box.


************** Exception Text **************

Microsoft.Mashup.Client.ClientShared.Com.ComWrapperException: Cannot cast null to type 'System.Double'. ---> System.NullReferenceException: Object reference not set to an instance of an object.

at Microsoft.Mashup.Client.ClientShared.Com.ComWrapper.As[T](Object value)

--- End of inner exception stack trace ---

at Microsoft.Mashup.Client.ClientShared.Com.ComWrapper.As[T](Object value)

at Microsoft.Mashup.Client.Excel.Com.ExcelComWrapper.AsIntFromDouble(Object value)

at Microsoft.Mashup.Client.Excel.Com.Application.get_Build()

at Microsoft.Mashup.Client.Excel.Com.ApplicationFeatures..ctor(IApplication application)

at Microsoft.Mashup.Client.Excel.Com.Application..ctor(Object application, Boolean enableEvents)

at Microsoft.Mashup.Client.Excel.AddIn.TryCreateApplication(Object appObject, IApplication& application)

at Microsoft.Mashup.Client.Excel.AddIn.Extensibility.IDTExtensibility2.OnConnection(Object application, ext_ConnectMode connectMode, Object addInInst, Array& custom)


*******
<Remaining message in attached word file>
*******


Second Error:
See the end of this message for details on invoking

just-in-time (JIT) debugging instead of this dialog box.


************** Exception Text **************

Microsoft.Practices.Unity.ResolutionFailedException: Resolution of the dependency failed, type = "Microsoft.Mashup.Host.Document.IApplicationConstants", name = "(none)".

Exception occurred while: while resolving.

Exception is: InvalidOperationException - The current type, Microsoft.Mashup.Host.Document.IApplicationConstants, is an interface and cannot be constructed. Are you missing a type mapping?

-----------------------------------------------

At the time of the exception, the container was:


Resolving Microsoft.Mashup.Host.Document.IApplicationConstants,(none)

---> System.InvalidOperationException: The current type, Microsoft.Mashup.Host.Document.IApplicationConstants, is an interface and cannot be constructed. Are you missing a type mapping?

at Microsoft.Practices.ObjectBuilder2.DynamicMethodConstructorStrategy.ThrowForAttemptingToConstructInterface(IBuilderContext context)

at BuildUp_Microsoft.Mashup.Host.Document.IApplicationConstants(IBuilderContext )

at Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlan.BuildUp(IBuilderContext context)

at Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context)

at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)

at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable`1 resolverOverrides)

--- End of inner exception stack trace ---

at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable`1 resolverOverrides)

at Microsoft.Practices.Unity.UnityContainer.Resolve(Type t, String name, ResolverOverride[] resolverOverrides)

at Microsoft.Practices.Unity.UnityContainerExtensions.Resolve[T](IUnityContainer container, ResolverOverride[] overrides)

at Microsoft.Mashup.Host.Document.DependencyInjectionService.Resolve[T]()

at Microsoft.Mashup.Host.Document.ClientConfig.ClientConfigManager..ctor()

at Microsoft.Mashup.Host.Document.ClientConfig.ClientConfigManager.get_Instance()

at Microsoft.Mashup.Client.Excel.AddIn.Extensibility.IDTExtensibility2.OnDisconnection(ext_DisconnectMode disconnectMode, Array& custom)


*******
<Remaining message in attached word file>
*******
 

Attachments

  • First .NET Framewrok Error Message.jpg
    First .NET Framewrok Error Message.jpg
    53.3 KB · Views: 4
  • Second .NET Framewrok Error Message.jpg
    Second .NET Framewrok Error Message.jpg
    60.2 KB · Views: 5
  • .NET Framework Error.docx
    63.5 KB · Views: 0
That error is usually result of error when you have connection via PowerQuery / PowerPivot to external source.

Validate that all your connections are valid and that you have access to the connected file.
 
Hi Chihiro,

Thank you for your reply.

There are no external connections yet to the workbook.

The following is performed:
1. When you start the workbook, it checks the following:
If MS Outlook is open Then
-Display UserForm and all goes well
Else
-Displays a User defined message "Outlook is not opened"
-quits the application.
End if

Appreciate your help

Regards,
Don



Below related code:

Code:
ThisWorkbook
' ----------------------------------------------------------------
' Purpose: Task related to workbook open
' ----------------------------------------------------------------
Private Sub Workbook_Open()
  On Error GoTo Catch_Workbook_Open
  Module_Name = "Workbook_Open"
  SetApplicationFalse

  Set ws = WorkSheets("Main Menu")
  
  Application.Visible = False
  'Check if MS Outlook is open GetEmailAddress (SuccessStatus) If not then close
  If CheckOutlookOpen = 1 Then
     SetApplicationTrue
     ActiveWorkbook.Close (True)
     Exit Sub
  Else
    UserForm1.IMMaleUser.Visible = True
    UserForm1.TBUserID = UserId
  
    Me.ActiveSheet.TBWelcome.Text = "Welcome " & FirstName
    UserForm1.Show
  End If
Done:
  Exit Sub
  
Catch_Workbook_Open:
    Call ListExceptions(Module_Name, Err.Number, Err.Description)
    Application.Visible = True
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
  On Error GoTo Catch_Workbook_BeforeClose
  Module_Name = "Workbook_BeforeClose"
  CheckToCloseApplication
Done:
  Exit Sub
  
Catch_Workbook_BeforeClose:
    Call ListExceptions(Module_Name, Err.Number, Err.Description)
    Application.Visible = True
    Application.Quit
End Sub



Code:
Module - Email

' ----------------------------------------------------------------
' Purpose: Check if MS Outlook is Open
' ----------------------------------------------------------------
Public Function CheckOutlookOpen() As Integer
  On Error GoTo Catch_CheckOutlookOpen
  Dim SpacePos, TotalLen, AtSign, AtDot, i, Success As Integer
  Module_Name = "CheckOutlookOpen"

  Set oOutlook = GetObject(, "Outlook.Application")
  ServerName = "abc.com"
    
  If oOutlook Is Nothing Then
     Success = 1
  End If
  If Success = 1 Then
     MsgBox "Please open MS Outlook and try again accessing this application. Exiting!."
     CheckOutlookOpen = 1
     Exit Function
  End If
  'Loop through the Accounts in Outlook
  For i = 1 To oOutlook.session.Accounts.Count
    TotalLen = Len(oOutlook.session.Accounts.Item(i))
    AtSign = InStr(1, oOutlook.session.Accounts.Item(i), "@")
    CheckServerName = LCase(Right(oOutlook.session.Accounts.Item(i), TotalLen - AtSign))
      
    'Check for the concerned Server Name
    If ServerName = CheckServerName Then
       AtDot = InStr(1, oOutlook.session.Accounts.Item(i), ".")
       SpacePos = InStr(1, oOutlook.session.CurrentUser, " ")
       FirstName = Left(oOutlook.session.CurrentUser, SpacePos - 1)
       UserId = LCase(Left(oOutlook.session.Accounts.Item(i), AtSign - 1))
      
       Success = 0
       Exit For
    End If
      
  Next i
  If Success = 1 Then
     CheckOutlookOpen = 1
     MsgBox "Invalid User Name. Please contact System Administrator"
  End If
Done:
    UserEmailID = UserId & "@" & CheckServerName
    SetApplicationTrue
    CheckOutlookOpen = 0
    Exit Function
Catch_CheckOutlookOpen:
    SetApplicationTrue
  
    CheckOutlookOpen = 1
  
    If Err.Number = 429 Or _
       Err.Number = 462 Or _
       Err.Number = 0 Or _
       oOutlook Is Nothing Then   'this error popsup when outlook is not open
          MsgBox "2 Please open MS Outlook and try again accessing this application. Exiting!.", vbCritical, _
                 "MS Outlook not open"
    Else
      MsgBox Module_Name & "  2"
      Call ListExceptions(Module_Name, Err.Number, Err.Description)
    End If
End Function


Code:
Module - General
' ----------------------------------------------------------------
' Purpose: To check if any other workbooks are open, before closing
'          the Excel application
' ----------------------------------------------------------------
Public Function IsAnyWorkbookOpen() As Boolean
  On Error GoTo Catch_IsAnyWorkbookOpen
  Module_Name = "IsAnyWorkbookOpen"
  If Application.Workbooks.Count = 0 Or Application.Workbooks.Count = 1 Then
    IsAnyWorkbookOpen = False
  Else
    IsAnyWorkbookOpen = True
  End If
Done:
  Exit Function
Catch_IsAnyWorkbookOpen:
    IsAnyWorkbookOpen = True
    Call ListExceptions(Module_Name, Err.Number, Err.Description)
End Function

' ----------------------------------------------------------------
' Purpose: During workbook close, check if application also needs
'          to be closed
' ----------------------------------------------------------------
Sub CheckToCloseApplication()
  On Error GoTo Catch_CheckToCloseApplication
  Module_Name = "CheckToCloseApplication"
  If IsAnyWorkbookOpen Then
    Application.Visible = True
    ActiveWorkbook.Close savechanges:=False
  Else
    Application.Quit
  End If
Done:
  Exit Sub
Catch_CheckToCloseApplication:
    Call ListExceptions(Module_Name, Err.Number, Err.Description)
End Sub


Code:
' ----------------------------------------------------------------
' Purpose: Set Application function off BEFORE code execution
' ----------------------------------------------------------------
Sub SetApplicationFalse()
  On Error GoTo Catch_SetApplicationFalse
  Module_Name = "SetApplicationFalse"
  With Application
    .EnableEvents = False
    .ScreenUpdating = False
  End With
Done:
  Exit Sub
Catch_SetApplicationFalse:
    Call ListExceptions(Module_Name, Err.Number, Err.Description)
End Sub

' ----------------------------------------------------------------
' Purpose: Set Application function on AFTER code execution
' ----------------------------------------------------------------
Sub SetApplicationTrue()
  On Error GoTo Catch_SetApplicationTrue
  Module_Name = "SetApplicationTrue"
  With Application
    .EnableEvents = True
    .ScreenUpdating = True
  End With
Done:
  Exit Sub
Catch_SetApplicationTrue:
    Call ListExceptions(Module_Name, Err.Number, Err.Description)
End Sub

' ----------------------------------------------------------------
' Purpose: Handling of exception message
' ----------------------------------------------------------------
Sub ListExceptions(pModuleName As String, pErrNumber As Integer, pErrDescription As String)
  On Error GoTo Catch_ListExceptions
  Module_Name = "ListExceptions"
  MsgBox "Module         : " & pModuleName & Chr(10) & _
         "---------------------" & Left(String(Len(pModuleName), "-"), Len(pModuleName)) & Chr(10) & _
         "Error Number: " & pErrNumber & Chr(10) & _
         "Description    : " & pErrDescription, _
         vbCritical, "Applicatio Error"
Done:
  Exit Sub
Catch_ListExceptions:
    MsgBox Module_Name & Chr(10) & Err.Number & Chr(10) & Err.Description
End Sub
 
Last edited by a moderator:
That's a lot to go through.

But when do you get the error? When Outlook is open? Or when it's closed?

When I tested the code, it will raise error at below location in the code if Outlook is closed.
Function CheckOutlookOpen()
Code:
    If Err.Number = 429 Or _
      Err.Number = 462 Or _
      Err.Number = 0 Or _
      oOutlook Is Nothing Then  'this error popsup when outlook is not open
        MsgBox "2 Please open MS Outlook and try again accessing this application. Exiting!.", vbCritical, _
                "MS Outlook not open"
    Else
      MsgBox Module_Name & "  2"
      Call ListExceptions(Module_Name, Err.Number, Err.Description)
    End If

But I suspect something within your system has changed to cause this error. I can't replicate your Mashup error on my side.

For further tracing, you'd need to upload file where it throws error. If that can't be done, I'd recommend posting it in MS support forum with all the details of the error along with when it happens etc.
 
Thank you Chihiro,

The system error comes only when Outlook is closed. When that is the case it should displays the below message and immediately the system error message (which is not required)

Function CheckOutlookOpen()
Code:
        MsgBox "2 Please open MS Outlook and try again accessing this application. Exiting!.", vbCritical, _
                "MS Outlook not open"
 
Last edited by a moderator:
Then just change the part I mentioned to...
Code:
    If CheckOutlookOpen = 1 Then
        MsgBox "2 Please open MS Outlook and try again accessing this application. Exiting!.", vbCritical, _
                "MS Outlook not open"
    End If
 
Thanks Chihiro.

I tried the above option as well.
Also, I removed all the exception handling and instead gave on error resume next, in vain.

Up until this afternoon, all was well.
 
Last edited by a moderator:
Then just change the part I mentioned to...
Code:
    If CheckOutlookOpen = 1 Then
        MsgBox "2 Please open MS Outlook and try again accessing this application. Exiting!.", vbCritical, _
                "MS Outlook not open"
    End If


Just to let you know, the error is not being displayed anymore as I have uninstalled any ".net" related addins/software

Thanks again,
Don
 
Back
Top