ActivationException数据库连接上的企业库

时间:2014-08-27 14:10:33

标签: c# enterprise-library-5

在我的64位机器上,我有visual studio 2012,更新4和oracle 12,包括ODP.net

当我尝试建立联系时,我得到了一个例外。连接字符串是什么并不重要,所以我猜测它没有那么远,它是一个引用/ dll问题?

典型的电话:

EnterpriseLibraryContainer.Current.GetInstance<Database>(AppSettingsHandler.ConnectionStringName));

我的连接字符串如下所示都失败了(它在另一台开发机器上运行正常):

<connectionStrings>
  <add name="DEV64" connectionString="Data Source=dev3;User Id=PISYSTEM;Password=xxx" providerName="Oracle.ManagedDataAccess.Client" />
  <add name="DEV86" connectionString="Data Source=dev3;User Id=PISYSTEM;Password=xxx" providerName="System.Data.OracleClient"/>
</connectionStrings>

数据库很好,项目也是如此,因为它在另一台开发机器上工作正常,所以我认为它与Enterprise Library存在某种配置问题。各种搜索只是随机提示不​​正确的dll等,但这是使用nuget在.NET中完成的所有开箱即用的东西。看起来有点废话的企业库有&c; \ home \ chris&#39;嵌入式,但我看到这个文件夹搜索互联网,所以它必须就是这样。

Microsoft.Practices.ServiceLocation.ActivationException was unhandled
  HResult=-2146233088
  Message=Activation error occured while trying to get instance of type Database, key "DEV64"
  Source=Microsoft.Practices.ServiceLocation
  StackTrace:
       at Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key) in c:\Home\Chris\Projects\CommonServiceLocator\main\Microsoft.Practices.ServiceLocation\ServiceLocatorImplBase.cs:line 57
       at Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance[TService](String key) in c:\Home\Chris\Projects\CommonServiceLocator\main\Microsoft.Practices.ServiceLocation\ServiceLocatorImplBase.cs:line 103
       at PI.Data.Services.DataManager.CreateContext() in c:\dev\PositionalImprovement\PI.Data\PI.Data.Services\DataManager.cs:line 20
       at PI.Business.Services.MapDataManager.getBatchList(Int32 statusID, String sortOrder) in c:\dev\PositionalImprovement\PI.Business\PI.Business.Services\MapDataManager.cs:line 44
       at PIClient.MainForm.loadBatchListGrid(Int32 batchStatusID, String sort_Order) in c:\dev\PositionalImprovement\PIClient\PIClient\MainForm.cs:line 855
       at PIClient.MainForm.openToolStripButton_Click(Object sender, EventArgs e) in c:\dev\PositionalImprovement\PIClient\PIClient\MainForm.cs:line 350
       at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
       at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
       at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ToolStrip.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at PIClient.Program.Main() in c:\dev\PositionalImprovement\PIClient\PIClient\Program.cs:line 17
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: Microsoft.Practices.Unity.ResolutionFailedException
       HResult=-2146233088
       Message=Resolution of the dependency failed, type = "Microsoft.Practices.EnterpriseLibrary.Data.Database", name = "DEV64".
Exception occurred while: while resolving.
Exception is: InvalidOperationException - The type Database does not have an accessible constructor.
-----------------------------------------------
At the time of the exception, the container was:

  Resolving Microsoft.Practices.EnterpriseLibrary.Data.Database,DEV64

       Source=Microsoft.Practices.Unity
       NameRequested=DEV64
       TypeRequested=Database
       StackTrace:
            at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable`1 resolverOverrides)
            at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, String name, IEnumerable`1 resolverOverrides)
            at Microsoft.Practices.Unity.UnityContainer.Resolve(Type t, String name, ResolverOverride[] resolverOverrides)
            at Microsoft.Practices.Unity.UnityServiceLocator.DoGetInstance(Type serviceType, String key)
            at Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key) in c:\Home\Chris\Projects\CommonServiceLocator\main\Microsoft.Practices.ServiceLocation\ServiceLocatorImplBase.cs:line 49
       InnerException: System.InvalidOperationException
            HResult=-2146233079
            Message=The type Database does not have an accessible constructor.
            Source=Microsoft.Practices.Unity
            StackTrace:
                 at Microsoft.Practices.ObjectBuilder2.DynamicMethodConstructorStrategy.ThrowForNullExistingObject(IBuilderContext context)
                 at BuildUp_Microsoft.Practices.EnterpriseLibrary.Data.Database(IBuilderContext )
                 at Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlan.BuildUp(IBuilderContext context)
                 at Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context)
                 at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
                 at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable`1 resolverOverrides)
            InnerException:

任何想法?

感谢。

1 个答案:

答案 0 :(得分:0)

我卸载了Oracle ODAC客户端,重新安装,就好像通过魔术一样有效。尽管我昨天做了完全相同的步骤。