Saturday, June 13, 2020

[C#][Resolved] Could not load file or assembly 'Interop.Microsoft.Office.Core'

Error message:
'test.exe' (CoreCLR: DefaultDomain): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.1.5\System.Private.CoreLib.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'test.exe' (CoreCLR: clrhost): Loaded 'C:\Users\user\source\repos\test\bin\Debug\netcoreapp3.1\test.dll'. Symbols loaded.
'test.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.1.5\System.Runtime.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'test.exe' (CoreCLR: clrhost): Loaded 'C:\Users\user\source\repos\test\bin\Debug\netcoreapp3.1\Interop.Microsoft.Office.Interop.Excel.dll'. Module was built without symbols.
'test.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.1.5\mscorlib.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
An unhandled exception of type 'System.IO.FileNotFoundException' occurred in Unknown Module.
Could not load file or assembly 'Interop.Microsoft.Office.Core, Version=2.4.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.

Solution :
Look up "Dependencies" then "COM " in your project at solution explorer, 
found the reference "Interop.Microsoft.Office.Interop.Excel" you added to your project, 
click it and change the value of  "Copy Local" and "Embed Interop Types" As Yes



Reference:
https://stackoverflow.com/questions/28349576/could-not-load-file-or-assembly-interop-microsoft-office-core-version-2-4-0-0

No comments :

Post a Comment