Tuesday, July 31, 2012

Could not load file or assembly Oracle.DataAccess in SharePoint 2010

In our SharePoint 2010 environment we started using ODP.Net to connect to Oracle Database. We have installed the 64 bit ODP.Net software and tried to build a webpart which gets the data from Oracle DB and display it in a Gird. But while loading the webpart page in SharePoint after deployment, we got the issue with Oracle.DataAccess.dll. The error was "Could not load file or assembly 'Oracle.DataAccess'". Finally we have found that we needed to use 64 bit version Oracle.DataAccess.dll. For some reason we also had 32 bit version Oracle Access dll on our machine, so we had to find the 64 bit dll and correctly reference it in Visual Stuio, butild it and deploy to SharePoint Web App. Provided the steps below:

1.    Developed a web part which shows the data on button click from Oracle Database using a Stored Procedure with ODP.Net framework

2.    Referenced 64 bit Oracle dll from GAC and added the reference in Visual Studio

2.1  Steps for finding 64 bit dll from GAC

2.1.1      Go to command Prompt and enter the command “cd c:\Windows\assembly”, hit enter

2.1.2      Enter Command “dir Oracle.dataaccess.dll /s”, hit enter, now the screen should show like below:
                      

The above screen shows the references of Oracle.DataAccess.dll in GAC and their physical paths. We need to 64 bit dll path for SharePoint App.
3.    Make the Oracle dll path to 64 bit folder in GAC with the help of above screen, like below:
c:\Windows\assembly\GAC_64\Oracle.DataAccess\2.112.1.0__89b483f429c47342\oracle.dataaccess.dll
4.    Add the 64bit Oracle dll to Visual Studio solution, like below:
4.1  Go to Visual Studio Solution Explorer and click on “Add Reference”
4.2  That opens a dialogue like below:


Enter the dll path (found in step 2.1.2) in the File Name text box and hit enter, that shows the oracle.Dataaccess.dll as shown in the above diagram. Select the dll and click Ok.

5.    Now build the application and deploy the solution to SharePoint Web App

6.    Make sure that Oralce.DataAccess.dll is registered under safecontrol properly, as shown below:

<SafeControl Assembly="Oracle.DataAccess, Version=2.112.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" Namespace="Oracle.DataAccess" TypeName="*" Safe="True" SafeAgainstScript="False" />

This worked fine.

No comments:

Post a Comment

Access to XMLHttpRequest at 'from origin has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https. .net core angular

Issue: The angular application was getting error from API that the origin has been blocked by CORS policy. Solution: Make sure that the...