Click here to Skip to main content
15,901,284 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to transfer Excel file data to a MS SQL database.

I added References for Excel 12.0:
Microsoft.Office.Interop.Excel
Interop.ADODB
Interop.ADOR
Interop.ADOX
Interop.DAO

Error Code:
CSS
Could not load type 'Microsoft.Office.Interop.Excel._Application' from assembly 'Excel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. The type is marked as eligible for type equivalence, but the containing assembly is not loaded as fully trusted.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.TypeLoadException: Could not load type 'Microsoft.Office.Interop.Excel._Application' from assembly 'Excel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. The type is marked as eligible for type equivalence, but the containing assembly is not loaded as fully trusted.
Posted
Comments
ImmeShea 27-Nov-15 2:58am    
You should reconsider using of excel's automation in .NET web application, see here why (in short it's not intended to be use on server side and you can encounter a lot of unexpected issues). Instead you could try out a C# component for excel's processing, which is safe to use in ASP.NET environment.

1 solution

See this StackOverflow[^] answer.

Requires you to disable embedding interop assemblies and set a full trust parameter in the configuration file.
 
Share this answer
 

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