fsprojects / ExcelProvider

This library is for the .NET platform implementing a Excel type provider.
http://fsprojects.github.io/ExcelProvider/
The Unlicense
141 stars 51 forks source link

You can only use this provider with an absolute path for the excel file?? #76

Closed halcwb closed 4 years ago

halcwb commented 4 years ago

Description

When the path of the Excel file is relative. This will not work when moving the compiled code to a different location. The path will still be the absolute path of the original coding location.

Repro steps

Please provide the steps required to reproduce the problem

  1. Create a type with the type provider on a D disk

  2. Try to run the compiled code on a C disk

Expected behavior

If the path for the type is the same relative to the working directory, it should be found.

Actual behavior

The error you can observe is:

System.TypeInitializationException: The type initializer for 'MyTypeProvider' threw an exception. ---> System.TypeInitializationException: The type initializer for '<StartupCode$BlahBlah>.$Blah' threw an exception. ---> System.Exception: Could not open file 'D:\Development\MyExcel.xlsx'. DirectoryNotFoundException

The path that will be shown in the error message is the exact absolute path that was used when compiling the code.

Known workarounds

Using __SOURCE_DIRECTORY__ to create an absolute path gives the same result.

Effectively, this typeprovider can only moved to a location with the same exact absolute path! Meaning I would have to reconfigure a production machine with a D disk just to run this code??

Related information

N/A

halcwb commented 4 years ago

Stumbled upon this issue: https://github.com/fsprojects/ExcelProvider/issues/36.

Problem solved, pfff.

quintusm commented 4 years ago

@halcwb Glad you found a solution