How do I get Oracle.DataAccess.dll to work in VS? - oracle

I have a legacy Visual Studio (mainly VB, but some C# thrown in) web application that uses Oracle.DataAccess to access our data. Our production web server is 32-bit, so it has to use the 32-bit drivers, and I do have a 32-bit version of Oracle installed locally. I have two different versions of Oracle.DataAccess.dll, but neither works; each one throws a different error when the code calls (OracleConnection).Open().
One throws "Attempt to read or write protected memory"; the other throws a Null Reference Exception.
I can get it to work if I switch everything to the ManagedDataAccess driver, but that is not an option at production level.
What could be causing the two problems, and how can this be fixed without switching to ManagedDataAccess?
Update:
After looking at the comments, I have a feeling the problem is, the 32-bit DLL is trying to access my 64-bit Oracle installation rather than my 32-bit one. I have added the following to my web.config:
<configSections>
<section name="oracle.dataaccess.client" type="OracleInternal.Common.CustomSectionHandler, Oracle.DataAccess, Version=4.122.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</configSections>
<configuration>
<oracle.dataaccess.client>
<version number="*">
<settings>
<add name="DllPath" value="C:\Ora32\bin" />
</settings>
</version>
</oracle.dataaccess.client>
</configuration>
but I still get the "Object instance not set to an instance of an object" error. Here is the stack trace:
System.NullReferenceException
HResult=0x80004003
Message=Object reference not set to an instance of an object.
Source=Oracle.DataAccess
StackTrace:
at Oracle.DataAccess.Client.OracleException.get_Number()
at Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure, Boolean bCheck, Int32 isRecoverable, OracleLogicalTransaction m_OracleLogicalTransaction)
at Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, Object src, OracleLogicalTransaction m_oracleLogicalTransaction)
at Oracle.DataAccess.Client.OracleConnectionOCP.Open(OracleConnection con)
at Oracle.DataAccess.Client.OracleConnection.Open()
at {(OracleConnection variable).Open() call in my code}
I have a feeling it is ignoring the DLL Path setting in web.config, as when I change it to a directory that does not exist, I get the same error.

Related

are not permitted to be deserialized at this security level

I have an application that works everywhere else except between 2 server. Web and App. The Web uses .NET Remoting to the App server.
We have typeFilterLevel= Full and remoting works on Global.asax but not on .aspx pages.
Below is the error.
Raw url: /welcome.aspx
System.Security.SecurityException: Type System.Runtime.Remoting.ObjRef and the types derived from it (such as System.Runtime.Remoting.ObjRef) are not permitted to be deserialized at this security level.
Server stack trace:
at System.Runtime.Serialization.FormatterServices.CheckTypeSecurity(Type t, TypeFilterLevel securityLevel)
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.CheckSecurity(ParseRecord pr)
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ParseObject(ParseRecord pr)
at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run()
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Remoting.Channels.CoreChannel.DeserializeBinaryRequestMessage(String objectUri, Stream inputStream, Boolean bStrictBinding, TypeFilterLevel securityLevel)
at System.Runtime.Remoting.Channels.BinaryServerFormatterSink.ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, IMessage& responseMsg, ITransportHeaders& responseHeaders, Stream& responseStream)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at System.Runtime.Remoting.Activation.IActivator.Activate(IConstructionCallMessage msg)
at System.Runtime.Remoting.Messaging.ClientContextTerminatorSink.SyncProcessMessage(IMessage reqMsg)
at System.Runtime.Remoting.Activation.ActivationServices.Activate(RemotingProxy remProxy, IConstructionCallMessage ctorMsg)
at System.Runtime.Remoting.Proxies.RemotingProxy.InternalActivate(IConstructionCallMessage ctorMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at OnSIS.Common.Utilities..ctor()
at OnSIS.Web.Welcome..ctor()
at ASP.welcome_aspx..ctor()
at __ASP.FastObjectFactory_app_web_welcome_aspx_cdcab7d2_gkkoykn5.Create_ASP_welcome_aspx()
at System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp)
at System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath)
at System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig)
at System.Web.HttpApplication.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
The Zone of the assembly that failed was:
MyComputer 2017/07/17 09:43:25
Again this all works perfectly fine exact same code in production servers and a dozen test server. But our Production Support server decided it just does not want to work anymore. I am looking for what to check that could have gone wrong on either the web or app server to cause the above error.
REMOTECONFIG(Webserver)
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.runtime.remoting>
<application>
<channels>
<channel ref="http" useDefaultCredentials="true" port="0">
<clientProviders>
<formatter ref="binary" typeFilterLevel="Full" />
</clientProviders>
</channel>
</channels>
<client url="http://10.10.10.10/AppServer">
<activated type="MyApp.Common.Utilities,MyApp.Common" />
</client>
</application>
</system.runtime.remoting>
</configuration>
WEBCONFIG(APPserver)
<?xml version="1.0"?>
<configuration>
<system.runtime.remoting>
<application>
<service>
<activated type="MyApp.Common.Utilities,MyApp.Common"/>
</service>
<channels>
<channel ref="http"/>
<serverProviders>
<formatter ref="binary" typeFilterLevel="Full" />
</serverProviders>
</channels>
</application>
</system.runtime.remoting>
</configuration>
This issue is caused by v6 of the New Relic monitoring agent. Specifically, a new DLL to support tracing for async code (something not previously supported by New Relic's agent).
If uninstalling the agent or reverting to an earlier version isn't possible, the async wrapper can be deleted (C:\Program Files\New Relic.NET Agent\Extensions\NewRelic.Providers.CallStack.AsyncLocal.dll). This will restore .NET Remoting functionality, though at the cost of New Relic not being able to instrument async methods in your code.
After 2 weeks of searching we finally found out what the issues was. Our Operations team installed some monitoring software I believe was New Relic. They did not tell anyone nor did they keep track of or tell anyone what they were doing. We uninstalled the software and the environment is back up and running. This is what happens when you make several changes to an environments all at once. You loose track of what you did and what caused the environment to go down.

ConnectionString Exception After Installing WebService

I have a webservice that I am using to get information from users. Before installing the service, it works fine. After installing the service, I am getting an exception "Object reference not set to an instance of an object." The WCF is referencing a dll where validating and writing to the database and return the results. The dll library has an app config where I added the connection string
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<clear/>
<add name="reqInformation" connectionString="Data Source=databasesourceInitial Catalog=databasename;Persist Security Info=True;User ID=username;password=password" providerName="System.Data.SqlClient"/>
</connectionStrings>
</configuration>
I have this class that is getting the connection string
public abstract class BASEClass
{
public static string GetConnectionString
{
get
{
return ConfigurationManager.ConnectionStrings["reqInformation"].ConnectionString;
}
}
}
I added the same connection string to the wcf config file.
In addition, I added a test project to test the service before installing it, it worked fine. I installed the WCF Service and ran the test project again, and it failed. The exception was Object reference not set to an instance of an object.
What am I doing wrong here?
The app config was added to the service Library; however, the service library was not the executing assembly. As a result, it was giving that exception. I moved the connection string int he executing assembly, recompile the code, re-install the service, and test it. All things are working as expected.

Exception thrown when creating sqlite .net entity data model

I'm trying to get sqlite working with linq. So far I've:
installed the ADO.net providers from http://sourceforge.net/projects/sqlite-dotnet2/files/SQLite%20for%20ADO.NET%202.0/
installed both the 32 and 64 bit sqlite .net from http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki
Now I can create an entity data model using an sqlite database as the source. Whenever I try to create a new instance of the data model (in a wpf component that is getting displayed) I get the following exception:
A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll
Additional information: 'The invocation of the constructor on type myprogram.mycomponent' that matches the specified binding constraints threw an exception.' Line number '13' and line position '37'.
The mycomponent constructor is simply:
private void myprogram()
{
InitializeComponent();
pricesEntities pe = new pricesEntities();
}
When I open the design view for the window that displays the component, I get an
ArgumentException was thrown on "mycomponent": Cannot create an instance of "mycomponent".
An Unhandled Exception has occurred
The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.
at System.Data.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString)
at System.Data.EntityClient.EntityConnection..ctor(String connectionString)
at System.Data.Objects.ObjectContext.CreateEntityConnection(String connectionString)
at System.Data.Objects.ObjectContext..ctor(String connectionString, String defaultContainerName)
at myprogram.pricesEntities..ctor() in <path>\prices.Designer.cs:line 34
at myprogram.ItemList.InitializePriceList() in <path>\ItemList.xaml.cs:line 34
at myprogram.ItemList..ctor() in <path>\ItemList.xaml.cs:line 29
My app.config contains the following connection string:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<add name="pricesEntities" connectionString="metadata=res://*/prices.csdl|res://*/prices.ssdl|res://*/prices.msl;provider=System.Data.SQLite;provider connection string='data source="<path>\prices.db"'" providerName="System.Data.EntityClient" />
</connectionStrings>
</configuration>
I tried copying the app.config file to the directory of the executable, as was suggested here and other places. That did not help. Note that this is a different issue than The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid
I have only one project (a wpf application) that I am trying to get to work.
Figured out it was because it was an assembly build for the 2.x runtime, so I added the useLegacyV2RuntimeActivationPolicy element to my app.config and that resolved the issue.

CLR Can't find a type, even though it's in the same assembly

I'm troubleshooting a WCF problem in our application, and turned on WCF tracing with the WCF Service Configuration Editor in VS 2010, which added the following sharedListener to the web.config:
<sharedListeners>
<add initializeData="D:\Logs\CRCCustomerService\Web_tracelog.svclog"
type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
name="ServiceModelTraceListener" traceOutputOptions="Timestamp">
<filter type="" />
</add>
</sharedListeners>
Now, when I take steps to reproduce my error, I'm getting an exception thrown from the System.Diagostics library saying that it can't find XmlWriterTraceListener:
Stack Trace:
System.TypeInitializationException: The type initializer for 'System.ServiceModel.DiagnosticUtility' threw an exception. ---> System.Configuration.ConfigurationErrorsException: Couldn't find type for class System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.
at System.Diagnostics.TraceUtils.GetRuntimeObject(String className, Type baseType, String initializeData)
at System.Diagnostics.TypedElement.BaseGetRuntimeObject()
at System.Diagnostics.ListenerElement.GetRuntimeObject()
at System.Diagnostics.ListenerElement.GetRuntimeObject()
at System.Diagnostics.ListenerElementsCollection.GetRuntimeObject()
at System.Diagnostics.TraceSource.Initialize()
at System.Diagnostics.TraceSource.get_Listeners()
And it goes on for several more lines, but this establishes the context.
My question is, since, according to ObjectBrowser and Reflector, XmlWriterTraceListener is a member class of the same assembly that System.Diagnostics is, how can it NOT not be able to find it?
And secondly, since every single line in the exception stack comes from system code, how on earth do I begin to debug the root cause here?
Are you using .NET 4.0?
If not, you have to beware the service config utility. It will hard code the version of the listener to 4.0 and you'll need to manually change your web.config

Error after migrating a solution from MVC 1.0.0.0 Visual Studio 2008 to MVC 2.0.0.0 Visual Studio 2010 (IControllerFactory )

After migrating a solution from MVC 1.0.0.0 Visual Studio 2008 to MVC 2.0.0.0 Visual Studio 2010 I get the following error:
The controller factory type 'MyLib.MyControllerFactory' must implement the IControllerFactory interface.
Parameter name: controllerFactoryType
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.ArgumentException: The controller factory type 'MyLib.MyControllerFactory' must implement the IControllerFactory interface.
Parameter name: controllerFactoryType
Source Error:
Line 35: protected void Application_Start()
Line 36: {
... container initialization ...
Line 38: ControllerBuilder.Current.SetControllerFactory(typeof(MyControllerFactory));
MyLib is an external shared library implemented in MVC 1.0.0.0
MyLib is an external shared library implemented in MVC 1.0.0.0
You will have to recompile (if you have the source code) or ask the author of the library to provide you a version compiled against System.Web.Mvc Version 2.0.0.0 or this won't work.
Here's workaround I've found to make work my MVC 1.0.0.0 dependency under my MVC 2.0 website migrated to Visual Studio 2010.
In the Application_start in Global.asax I just instantiated the IControllerFactory using the implementation class MyControllerFactory instead of trying to get its type:
ControllerBuilder.Current.SetControllerFactory((IControllerFactory) new MyControllerFactory());
With that error fixed, then I got another crash:
<b>Entry point was not found. </b>
<b>Description:</b> 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.
<b>Exception Details:</b> System.EntryPointNotFoundException: Entry point was not found.
<b>Source Error: </b>
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
<b>Stack Trace: </b>
[EntryPointNotFoundException: Entry point was not found.] System.Web.Mvc.IControllerFactory.CreateController(RequestContext requestContext, String controllerName) +0
System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory) +181
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +85
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +392
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +263
This was produced because the legacy MVC 1.0 library wasn't able to resolve MVC the reference to the interface in MVC 2.0 library loaded in the application.
I solved this by adding the following section in the config file to add assembly binding from System.Web.Mvc 1.0.0.0 to System.Web.Mvc 2.0.0.0:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<!-- Binding to help Common library MVC 1 code find the classes in MVC 2 -->
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
I also had to add this configuration block to the app.config file in my unit tests project to fix the broken tests.

Resources