Click here to Skip to main content
16,022,060 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB
+ TargetSite	{System.Object CreateObject(System.String, System.String)}	
                                   System.Reflection.MethodBase {System.Reflection.RuntimeMethodInfo}
Cannot call method System.Reflection.MemberInfo.get_CustomAttributes in this context.
________________________________________________________________________

IDE: Visual Studio   /     VB.net
---------------------------------------------------------------------
Imports System.Reflection
Imports System.Reflection.MethodBase
Imports Excel = Microsoft.Office.Interop.Excel
Imports System.Runtime.InteropServices

Public Class ResumenFin
. . . . .

Private Sub PrepareResumenXLSX()
   Dim MiLibro As Excel.Application
   Dim objBooks As Excel.Workbook
   MiLibro = CreateObject("Excel.Application")          <== exception ocurrs in runtime
. . . . .
End Sub


What I have tried:

Activate as automatic SERVICES: ActiveX Installer (AxInstSV) an restart it
C:\WINDOWS\system32> sfc /scannow
C:\WINDOWS\system32> regsvr32 scrrun.dll
---
For a while in the same session it works fine, but suddenly the exception appears
I have been reading a lot about it, especially about the Reflection method, but I have not understood it.
I would greatly appreciate your help.
Posted
Updated 8-Oct-24 18:18pm
v2

1 solution

ScrRun.dll is the Windows Scripting Runtime. It has nothing to do with what your code snippet is doing.

My first guess for the problem is you wrote this code against a certain version of Office and that version, or a compatible version, is no longer installed on the machine.

Your tabs said VS2002, and that is a VERY OLD version of Visual Studio. The versions of the .NET Framework that version supported are no longer supported themselves.

If that's the case, I would imagine the code has to be updated and recompiled against newer versions of Office and .NET using a updated Visual Studio version.

If at all possible, I would also avoid using Office Interop.
 
Share this answer
 
v2
Comments
Jose Jorge Duran yesterday    
Sorry, I had to specify VS 2022, but interesting how can I work without interop, ¿do you have some suggest?
Thanks a lot
Dave Kreskowiak yesterday    
That depends on what you're doing with Office. If you're just creating a file, then you can use the OpenSDK library to do that for any Office document.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900