Im using Visual Studio 2010 Ultimate, Project is c# MVC3 Razor
I have a project that is running without any problems on local machine using the MySql (from online server) database just fine, but when I upload it and when it gets to the part where needs to get data from MySql server it gives me this error:
Unable to find the requested .Net Framework Data Provider. It may not
be installed.
This is my connection string from Web.config for MySql wich like this is running fine when I debug project locally. Reads the info from tables and shows on the page.
<add name="istakipDBContext"
connectionString="Server=xxx.xxx.xxx.xxx; Database=xxx; Uid=xxx;
Pwd=xxx;" providerName="MySql.Data.MySqlClient" />
And this is the whole stack trace:
Server Error in '/' Application. Unable to find the requested .Net
Framework Data Provider. It may not be installed. 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: Unable to find the
requested .Net Framework Data Provider. It may not be installed.Source Error:
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.Stack Trace:
[ArgumentException: Unable to find the requested .Net Framework Data
Provider. It may not be installed.]
System.Data.Common.DbProviderFactories.GetFactory(String
providerInvariantName) +1420503
System.Data.Entity.Internal.LazyInternalConnection.TryInitializeFromAppConfig(String
name) +393
System.Data.Entity.Internal.LazyInternalConnection.Initialize() +47
System.Data.Entity.Internal.LazyInternalConnection.get_ConnectionHasModel()
+9 System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
+262 System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type
entityType) +17
System.Data.Entity.Internal.Linq.InternalSet1.Initialize() +63
1.GetEnumerator() +15
System.Data.Entity.Internal.Linq.InternalSet
System.Data.Entity.Infrastructure.DbQuery1.System.Collections.Generic.IEnumerable<TResult>.GetEnumerator()
1..ctor(IEnumerable
+40 System.Collections.Generic.List1 collection) +315 System.Linq.Enumerable.ToList(IEnumerable
1
source) +58 onlinetercume.Controllers.istakiplerController.Index()
in
C:\wwwroot\nps\nps\Controllers\istakiplerController.cs:21
lambda_method(Closure , ControllerBase , Object[] ) +62
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase
controller, Object[] parameters) +17
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext
controllerContext, IDictionary2 parameters) +208
2
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext
controllerContext, ActionDescriptor actionDescriptor, IDictionary
parameters) +27
System.Web.Mvc.<>c_DisplayClass15.b_12()
+55 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter
filter, ActionExecutingContext preContext, Func1 continuation) +263
1 filters, ActionDescriptor actionDescriptor,
System.Web.Mvc.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14()
+19 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext
controllerContext, IList
IDictionary2 parameters) +191
1.b__7(IAsyncResult
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext
controllerContext, String actionName) +343
System.Web.Mvc.Controller.ExecuteCore() +116
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext)
+97 System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext
requestContext) +10
System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +37
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21
System.Web.Mvc.Async.<>c__DisplayClass8
) +12 System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62 System.Web.Mvc.<>c_DisplayClasse.b_d() +50
System.Web.Mvc.SecurityUtil.b_0(Action f) +7
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action)
+22 System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult
result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
+8970061 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184Version Information: Microsoft .NET Framework Version:4.0.30319;
ASP.NET Version:4.0.30319.272
Best Answer
The error is clear, it cannot find the MySQL data provider
If you deployed to your production server perhaps you have not deployed the MySQL component, check you have deployed the MySQL dll's to the bin folder of your application
A common problem is when you have the component installed in the GAC in the development sandboxes and they are not present in the production server, verify if the dll is in the GAC:
The Global Assembly Cache (GAC) is located in:
%windir%\assembly
You may force the references from your project to be deployed to the production server by selecting the copy always property of the assembly to true, however, if it is configured to resolve the reference from the GAC then it's better to install the component in the GAC in the production box:
These are the steps to install the MySQL data provider in the GAC
http://blog.jeffreymcmanus.com/555/installing-the-mysql-adonet-connector-into-the-global-assembly-cache/
As a summary:
Solution 1:
Run the following command to register the MySQL data provider in the GAC (this way that version of your MySQL data provider will be installed globally available to all applications in the server)
"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\gacutil.exe" /i MySql.Data.dll
Solution 2:
Copy the
MySql.Data.dll
dll to the bin directory of your application