c# - asp.net core Oracle.DataAccess System.BadImageFormatException: Could not load file or assembly Oracle.DataAccess -


i've added oracle.dataaccess reference asp.net core project. i've installed oracle data provider .net when installed odac. make simple example dapper on project.

public class program {     const string connectionstring = "xxxxx";     public static void main(string[] args)     {         idbconnection connection = new oracleconnection(connectionstring);         string sql = "select * people  name='john'";         var r = connection.query<people>(sql);     } } 

the application wasn't running. getting error below when tried "dnx run" on project folder.

system.badimageformatexception: not load file or assembly 'oracle.dataaccess, version=4.121.2.0, culture=neutral, publickeytoken=89b483f429c47342' or 1 of dependencies. attempt made load program incorrect format.

if message, probably, means oracle.dataaccess dll doesn't exist in gac.

  1. open command line , go bin folder under odp.net e.g.

    cd c:\oracle\product\12.1.0\client_x86\odp.net\bin\4

  2. run command below

     oraprovcfg.exe /action:gac /providerpath:c:\oracle\product\12.1.0\client_x86\odp.net\bin\4\oracle.dataaccess.dll

after doing these steps able run project successfully.

badimageformat means dll not compatible runtime.

problem oracle has not yet released driver compatible .net core.

you still use available driver in asp.net core, when run on full desktop .net framework, not on .net core framework.

what should able solve remove dnxcore50 target project.json file targeting desktop framework.

doing means can run on windows now, later when oracle releases compatible driver have option target .net core framework.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -