1

I have a Windows Server 2008 x64 machine and have successfully connected a simple ASP.NET/C# application to an Oracle database using the ODAC 11g client. My next step, is adding this same oracle connection to a SharePoint web part (which is developed on the same machine). The SharePoint Server, Web Server, etc. all live on the same machine as well. I figured I could just add the Oracle.DataAccess reference to my SharePoint Web Part, add the oracle connection code, and be done... but ohh now... I am getting the following error when loading my web part through the browser with the oracle connection:

[BadImageFormatException: Could not load file or assembly 'Oracle.DataAccess, Version=2.112.1.1, Culture=neutral, PublicKeyToken=89b483f429c47342' or one of its dependencies. An attempt was made to load a program with an incorrect format.]

Can someone please help me debug this? I have the assembly in the GAC with the correct version. For some reason it is not seeing it? I am confused as to why a simple ASP.NET/C# application would work fine, but now that it is up on SharePoint it does not work. Any ideas?

SPECFIC ERROR:

[TargetInvocationException: Exception has been thrown by the target of an invocation.] at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck) at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache) at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache) at System.Activator.CreateInstance(Type type, Boolean nonPublic) at Microsoft.SharePoint.WebPartPages.SPWebPartReflectionHelper.GetDefaultControl(Type controlType) at Microsoft.SharePoint.WebPartPages.BinaryWebPartDeserializer.LoadInitialWebPart() at Microsoft.SharePoint.WebPartPages.BinaryWebPartDeserializer.Deserialize() at Microsoft.SharePoint.WebPartPages.SPWebPartManager.CreateWebPartsFromRowSetData(Boolean onlyInitializeClosedWebParts)

[BadImageFormatException: Could not load file or assembly 'Oracle.DataAccess, Version=2.112.1.1, Culture=neutral, PublicKeyToken=89b483f429c47342' or one of its dependencies. An attempt was made to load a program with an incorrect format.] at PortalOBIEEReportList.OBIEEReportList.OBIEEReportList..ctor()

3
  • Do you have oracle 10g installed on the same machine? Commented Jul 9, 2010 at 2:28
  • No, Oracle 11g is installed on the same machine... I am running ODAC 11g client as well. I am just confused since my non-SharePoint ASP.Net/C# application connected just fine. It seems as though it is a 32-bit vs 64-bit issue here, but everything is 11g/64-bit. Commented Jul 9, 2010 at 2:35
  • I even tried setting the platform to x64 in the VS project, but no luck. Commented Jul 9, 2010 at 2:53

2 Answers 2

1

You may need to enter a Safe Control setting for the oracle Data Access dll in the Web.Config file of your SharePoint application. The Safe Control setting explicitly identifies DLLs that the SharePoint runtime allows to be loaded.

The format is

<SafeControl Assembly="DLLName, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" 
    Namespace="DLLNameSpace" 
    TypeName="*" 
    Safe="True" 
    AllowRemoteDesigner="True" />

Information on adding a SafeControl.

A tool I use to help determine the Assembly name is .NET Reflector

Sign up to request clarification or add additional context in comments.

Comments

0

The Build Platform Target must be 'ANY CPU' or x64.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.