Unable to find the requested .Net Framework Data Provider in Oracle - odp.net

string constr = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=spp01)(PORT=1521))(CONNECT_DATA=(SID=Global)));User
Id=SYSMAN;Password=testman3";
string ProviderName = "Oracle.DataAccess.Client";
DbProviderFactory factory = DbProviderFactories.GetFactory(ProviderName);
I am able to connect to oracle in console and winforms application. The code above is in a seperate class library. I have installed 64bit ODAC.
The ORACLE.DATAACCESS is set to 2.x ver 2.112.3.0. I have checked machine.config entries Framework64 v2.0.50727 and v4.0.30319
type="Oracle.DataAccess.Client.OracleClientFactory, Oracle.DataAccess, Version=2.112.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
CPU = Any CPU Framework=3.5
When I call the same code from class library in ASP.net then I get the following error
System.ArgumentException was unhandled by user code
Message=Unable to find the requested .Net Framework Data Provider. It may not be installed.
Source=System.Data
StackTrace:
at System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName)
I have even set the apppool to allow 32-bit applications.
How do I resolve this error?

The error shows that the Oracle client is not installed on your system. To validate it you can run the line of code below:
System.Data.Common.DbProviderFactories.GetFactoryClasses()
You will get a DataTable of all the installed data providers. If Oracle.DataAccess.Client invarient is not listed in the DataTable then it means it is not installed.
I was also facing the same issue on one of our clients machine and on debugging i found that the Oracle client was installed from the Admin user and they were trying to access it from some other user.
On installing the Oracle client from current user resolves the problem.
Please don't forget to restart your application after installing the Oracle client.

You simply need the data provider. I had the same problem with Oracle 11g when deploying to a Windows Server 2008 R2 and after installing their data provider on the server it worked. Didn't work on the first shot though I had to restart the web app a few times.
To check if you have the ODAC on the server simply dump this string to a log somewhere or anywhere you can see it:
private String GetDbProviders()
{
// Retrieve the installed providers and factories.
DataTable table = DbProviderFactories.GetFactoryClasses();
StringBuilder bob = new StringBuilder();
// Display each row and column value.
foreach (DataRow row in table.Rows)
{
foreach (DataColumn column in table.Columns)
{
bob.AppendLine(" "+row[column]+" ");
}
}
return bob.ToString();
}

This is one of the common issues that all .NET developer who ever using the Oracle Client as Database will face.
Points to remember:
Make sure you have installed Oracle ODAC from Oracle.
Check if Oracle.DataAccess is properly installed:(Oracle.DataAccess should be there in DbProviderFactories section)
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.config
If oracle 32bit is installed make sure you're building an application in 32x.
Even if you have 32bit/64bit system and 32bit/64bit application. You should refer the same Oracle.Database DLL version as on DbProviderFactories in machine.config
Screenshot for reference
Quick Links:
Download Path - http://www.oracle.com/technetwork/database/windows/downloads/index-090165.html
Similar answer - ODP.NET Managed - Unable to find requested .Net Framework Data Provider

Uninstall the 64bit ODAC and install the 32 bit ODAC.

Related

Xul.dll missing dependencies after upgrade from Xulrunner and Gecko 14 to 33 due to Xpcom.dll conflict

I'm using Xulrunner and GeckoFX in a vb application (version 33.0-0.1 for both), and when debugging the application, the line
Gecko.Xpcom.Initialize(System.IO.Directory.GetCurrentDirectory() & "\xulrunner")
throws the exception:
Unable to load DLL 'xul': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
Note that regardless of how I call the Initialize() function, the exact same exception comes up. I've tried:
Gecko.Xpcom.Initialize()
Gecko.Xpcom.Initialize(System.IO.Directory.GetCurrentDirectory() & "\xulrunner")
Gecko.Xpcom.Initialize(System.IO.Directory.GetCurrentDirectory() & "\bin\xulrunner")
Gecko.Xpcom.Initialize("C:\full path here\xulrunner")
This question Unable to load DLL (Module could not be found HRESULT: 0x8007007E) led me to use Dependency walker to check the dll.
Checking the dll showed that I was "missing" a slew of other things, as shown below:
That in turn led me to Win 7, 64 bit, dll problems, which also didn't help. While DW does show some of the same missing DLLs, it's also showing other ones that aren't listed in that question.
Of the offered solutions in that question, I've tried:
reinstalling the VS Redistributable Package
running 'sfc /scannow'
I've noticed in the aforementioned question that some people are saying it's an issue with OCX files instead of the DLL, but I'm not sure how to even start on that end. I couldn't find any OCX files in the project directory.
I realize that the problem may also lie in how I implemented GeckoFX and Xulrunner. Previously, this application was working using SkyboundGecko, GeckoFX, and Xulrunner. It seems that the previous developer working on this application followed this tutorial (or something very similar) using version 14 of GeckoFX and Xulrunner. However, this recently started causing problems for some customers using the application, as there was an Xpcom.dll conflict with a different application they were using. This issue only applies to those customers which had application X (I don't remember the name) installed on their computer. Other computers did not have this issue.
A bit of research has led me to believe that more current versions of GeckoFX and Xulrunner no longer require XPCom.dll, which means that an upgrade should in theory resolve this issue.
Thus, I started (loosely) following this tutorial in order to upgrade Gecko and Xulrunner. I removed the previous reference to the Skybound.Gecko.dll, and replaced Xulrunner with a newer version. I also downloaded and extracted the GeckoFX DLLs and files. My Bin now looks like this:
I added the reference to Gecko back to the project, and changed any references of Skybound.Gecko.xxxx to Gecko.xxxx. (Perhaps this tells you something that I don't know/haven't realized, since the tutorials I've seen never use Gecko.xxx - the function calls, for example, are Xpcom.Initialize() instead of Gecko.Xpcom.Initialize())
I'm running Windows 8 on Windows Server 2012 R2 Standard, 64 bit OS.
Is there another way to avoid the Xpcom.dll conflict, and if not, how do I resolve this issue?
If any other information is required, comment and I'll try my best to provide it.
In my case this error is caused because of I initialised xulrunner in Form1_Load function. I resolved it by initialising xulrunner in public Form1() function.
Try to initialise xulrunner as shown below,
public Form1()
{
InitializeComponent();
Gecko.Xpcom.Initialize(#"C:\Users\PAVILION\Documents\visual studio 2010\Projects\SiteFilterAutomation\SiteFilterAutomation\bin\Debug\xulrunner\");
}
private void Form1_Load(object sender, EventArgs e)
{
geckoWebBrowser1.Navigate("www.google.com");
}

"Type 'System.Data.SqlClient.SqlConnection' is not defined." in .Net Web Site

I'm trying to get a .NET web site running on a network server, and while everything is set up and running locally on my machine (using IISExpress), when I deploy to a Windows Server 2008 server with IIS installed, I end up getting compilation errors when trying to use an SqlConnection:
Compiler Error Message: BC30002: Type 'System.Data.SqlClient.SqlConnection' is not defined.
Now, I have both import statements at the beginning of the source file as follows:
Imports System.Data.SqlClient
Imports System.Data
In the compilation warnings it lists a very strange error:
Warning: BC40056: Namespace or type specified in the Imports 'System.Data.SqlClient' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases.
Evidently, the compiler can't find System.Data.SqlClient. The IIS application pool is running .NET 2.0, and my site is targeting 3.5. I'm very new to .NET development, and I'm learning this as I go, but this has me stuck. Am I missing a dependency? Do I need SQL Server Management Studio installed on the server?
A couple of things
Inside your web application you might be missing the reference to System.Data
Right click on Solution Explorer
Add References
Click on .NET and find System.Data.dll
You may already have a class called SqlConnection (Your own), and there might be an ambiguity. Reference the Sqlclient/SqlConnection class directly System.Data.SqlClient.SqlConnection
I had this problem.
It's easy to solve it.
REPALCE
using Microsoft.Data.SqlClient;
instead of
using System.Data.SqlClient;

Clearscript files cannot be found on host

Like a lot of others I'm receiving the following error when deploying my ASP.Net MVC application:
Cannot load V8 interface assembly; verify that the following files are installed with your application: ClearScriptV8-32.dll, ClearScriptV8-64.dll, v8-ia32.dll, v8-x64.dll
Clearscript was installed as part of an effort to transform less files on the fly for page requests.
I have tested my application locally in ISS Express and ISS without a hitch.
As suggested here http://clearscript3.rssing.com/chan-14849437/all_p12.html I've also included the missing code libraries as resources to my project.
ClearScriptV8-32.dll, ClearScriptV8-64.dll, v8-ia32.dll, v8-x64.dll are all included in a folder ClearScript.V8 in the bin folder. Removing this folder does not resolve the issue.
At my wits end. Any help is appreciated.
the cause is that asp.net load instantly all libraries in /bin directory.
I added the following rule to ignore Clearscript assemblies, and it worked
<configuration>
<system.diagnostics>
<trace autoflush="true" />
</system.diagnostics>
<system.web>
<compilation>
<assemblies>
<remove assembly="ClearScriptV8-64" />
<remove assembly="ClearScriptV8-32" />
....
</assemblies>
</compilation>
...
To be clear this exception is not always caused by a missing ClearScriptV8-32.dll, ClearScriptV8-64.dll, v8-ia32.dll or v8-x64.dll. Oftentimes the issue is that a dll referenced by one of the aforementioned dlls cannot be found. In cases where the appropriate dlls are on the server installing the appropriate Visual C++ Redistributable will usually solve this transitive dependency issue.
According to the project's discussion forum ClearScript no longer supports Visual Studio 2012. Meaning the version of the Visual C++ Redistributable that needs to be installed on your server is dependent on the version of ClearScript your project is utilizing:
ClearScript Versions 5.0 - 5.3: Visual C++ Redistributable for Visual Studio 2012
ClearScript Versions 5.4 - .....: Visual C++ Redistributable for Visual Studio 2013
Might be a bit late but this may help others coming to this post.
This is a common error when you don't have the Visual C++ Redistributable for Visual Studio 2012 or above installed on the hosting server
http://www.microsoft.com/en-gb/download/details.aspx?id=30679
If you're deploying on Windows Server 2012 with IIS role, there are two things you should do to get ClearScriptV8 running:
As #no1sprite pointed out:
you have to install on the hosting server the Visual C++ Redistributable for Visual Studio 2012 or above:
http://www.microsoft.com/en-gb/download/details.aspx?id=30679
Make sure you place ClearScript.dll in website's bin\ folder, and ClearScriptV8-64.dll and v8-x64.dll into bin\ClearScript.V8.
Optional, for 32-bit applications/platforms:
If you use 32-bit platform, place ClearScriptV8-32.dll and v8-ia32.dll in website's bin\ClearScript.V8\ folder.
Also, In IIS Manager, right-click on site's Application pool and select "Advanced settings...". Set property "Enable 32-bit applications" to true.
This was seconds time starting some project with clearscript v8, and good I remembered what was the issue first time. Loading Native Lib v8.
You would think somewhere in GETTING STARTED or similar topic, devs from ClearScript should have mentioned that you need to have V8 native lib located in subfolders 'ia32' or 'x64' (Platform x86 or Platform x64 respectfully).
Create above subfolders. and place native v8 libs there (32bit into 'ia32', 64bit in 'x64').
I guess they forgot to write down that thought.
just as reminder...
source code taken from loader that helped me last time track the issue...
private static IntPtr LoadNativeLibrary()
{
var suffix = Environment.Is64BitProcess ? "x64" : "ia32";
var fileName = "v8-" + suffix + ".dll";
var messageBuilder = new StringBuilder();
var paths = GetDirPaths().Select(dirPath => Path.Combine(dirPath, deploymentDirName, fileName)).Distinct();
foreach (var path in paths)
{
var hLibrary = NativeMethods.LoadLibraryW(path);
if (hLibrary != IntPtr.Zero)
{
return hLibrary;
}
var exception = new Win32Exception();
messageBuilder.AppendInvariant("\n{0}: {1}", path, MiscHelpers.EnsureNonBlank(exception.Message, "Unknown error"));
}
var message = MiscHelpers.FormatInvariant("Cannot load V8 interface assembly. Load failure information for {0}:{1}", fileName, messageBuilder);
throw new TypeLoadException(message);
}
Oddly enough, this loader should have thrown more meaningful message in debug environment, but it didn't. Instead we have : FileNotFoundException with message "Could not load file or assembly 'ClearScriptV8' or one of its dependencies. The system cannot find the file specified.". Guess there in code elsewhere is another similar loader that actually doesn't use LoadLibrary but falls back to .Net default loader, giving meaningless Exception.
hope this helps others solve similar issues.
None of the answers worked for me. It is a Windows Service application.
Based on accepted answer;
I removed v8-ia32.dll & ClearScriptV8-32.dll (since my application is targeting x64)
It solved the issue.
Posted answers here did not work for me, but this did:
Visual Studio -> Tools -> Options -> Project and Solutions -> Web Projects -> check "Use 64 bit version of IIS Express for web sites and projects"

How to use signalr v2 beta in asp.net mvc 4

Before v2:
RouteTable.Routes.MapHubs();
In v2, MapHubs does not exist anymore. The wiki says to add a Startup class and a Configuration method and a call to app.MapHubs().
namespace MyAssembly
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
//Before v2
//RouteTable.Routes.MapHubs();
app.MapHubs();
}
}
}
But the method is never called, no error occurs, and ... no hub are setup.
I suppose there is some code to add to global.asax.cs
What is the secret ?
Try defining [assembly : OwinStartup(typeof(MyAssembly.Startup))] to see if your Startup class is being picked up.
EDIT: removed lines not relevant.
Solution !
<appSettings>
<add key="owin:AppStartup" value="MyNameSpace.Startup, MyNameSpace" />
</appSettings>
plus update both MVC4 (not to prerelease, but to latest stable version) and SignalR/owin nugets.
plus fix bugs in js client :
if disconnectTimeout=999000 then it is disabled. Must be set server-side with: GlobalHost.Configuration.DisconnectTimeout = TimeSpan.FromSeconds(999);
note: server side can not set a value < 6 (signalr throws an exception if DisconnectTimeout < 6). So use this magic number.
webSockets: set connection.socket = null in sockettransport, otherwise the call to start fails after a (manual) call to stop
serverSentEvents: prevent error caused by a reconnection attempt when the window is unloading
chrome fails with exception if signalr hub url not available (temporarily) : Instead of giving up try the next available protocol / try to reconnect.
I was able to get the 2.0 beta working by
Removing all references to the older version of SignalR, ie nuget uninstall of the library and double checking /bin
Installed SignalR 2.0.0-beta2 via Package Manager Console Install-Package Microsoft.AspNet.SignalR -Pre
Following the steps in the 1.x to 2.0 migration outlined here
And most importantly changing the project config to use Local IIS Web server instead of Visual Studio Developer Server (Cassini).
More info in the question/answer I posted here
In web.config there must be a fully qualified name of the class, e.g.
<appSettings>
<add key="owin:AppStartup" value="**My.Name.Space.Startup**, **AssemblyName**" />
</appSettings>
I had a problem when I put namespace instead of assembly name, but with the fully qualified name it works without any other changes to web.config!
UPDATE: I also followed the steps from the link: http://www.asp.net/vnext/overview/latest/release-notes#TOC13, i.e. removed a NuGet package "Microsoft.AspNet.SignalR.Owin"

WCF service not working after program update

I have recently added a WCF service reference to my program. When I perform a clean install of this program, everything seems to work as expected. But, when I install the program on a client which already has a previous version (without the new service reference) installed, I get a exception telling me the default endpoint for this particular service could not be found.
It seems that the appname.exe.config is not being updated with the new endpoint settings. Is there any reason for this and how can I force the installer to overwrite the config file? I'm using the default Visual Studio 2008 installer project with RemovePreviousVersions set to True.
Update:
My program encrypts the settings section after the first run with the following code
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
ConfigurationSection section = config.GetSection(sectionKey);
if (section != null)
{
if (!section.SectionInformation.IsProtected)
{
if (!section.ElementInformation.IsLocked)
{
section.SectionInformation.ProtectSection("DataProtectionConfigurationProvider");
section.SectionInformation.ForceSave = true;
config.Save(ConfigurationSaveMode.Full);
}
}
}
When I do not run the program before installing the new version the app.config gets updated.
You are right that it is the config file that is not updated.
There are several possibilities:
The installer has the old version of the config file
The installer does not have a config file and the program is using the old one on the machine
Try uninstalling the project first, then install and check that the config file has been copied in.