Reputation: 307
Developed an exe using .Net framework 4.0, EF 6.0. It works fine in machines where .Net framework 4.0, 4.5 full version installed.
But when I invoke the same exe from different machine's shared folder, it throws error. it is because of entityframework tag in the config.
Server Machine has shared folder with .Net 4.5 installed. SharedFolder contains the exe developed using .Net 4.0.
If user opens the exe of sharedFolder in servermachine, from clientmachine (4.0 installed) getting below error.
It works fine, when client and server machines have 4.5 framework.
Works, when opening directly in client (4.0) and server (4.5) machines.
Error
'System.Data.Entity.Internal.AppConfig' Type initializer for threw an exception
Stack Trace:
at System.Data.Entity.Internal.AppConfig.get_DefaultInstance()
at System.Data.Entity.DbContext..ctor(String nameOrConnectionString)
at ShipNet.Accounting.Data.SNACSEntities..ctor(String ConnectionString)
at ShipNet.Accounting.Data.Repository.BaseRepository..ctor()
at ShipNet.QnR.Presenter.frmMainPresenter.IView_GetSNAPSSystem()
at ShipNet.QnR2.UI.frmMain..ctor(String UserName)
at ShipNet.QnR2.UI.Program.Main(String[] args)
Inner Exception Source:
System.Configuration
.Net Framework : 4.0 Entity Framework : 6.0 database: sql server
my configuration file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="ERP-DB" connectionString="Data Source=testserver;Initial Catalog=db;user Id=**;Password=**" providerName="System.Data.SqlClient" />
</connectionStrings>
<entityFramework>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
</entityFramework>
<system.data>
<DbProviderFactories>
<add name="EF Caching Data Provider" invariant="EFCachingProvider" description="Caching Provider Wrapper" type="EFCachingProvider.EFCachingProviderFactory, EFCachingProvider, Version=1.0.0.0, Culture=neutral, PublicKeyToken=def642f226e0e59b" />
<add name="EF Tracing Data Provider" invariant="EFTracingProvider" description="Tracing Provider Wrapper" type="EFTracingProvider.EFTracingProviderFactory, EFTracingProvider, Version=1.0.0.0, Culture=neutral, PublicKeyToken=def642f226e0e59b" />
<add name="EF Generic Provider Wrapper" invariant="EFProviderWrapper" description="Generic Provider Wrapper" type="EFProviderWrapperToolkit.EFProviderWrapperFactory, EFProviderWrapperToolkit, Version=1.0.0.0, Culture=neutral, PublicKeyToken=def642f226e0e59b" />
</DbProviderFactories>
</system.data>
</configuration>
Upvotes: 0
Views: 190
Reputation: 307
one more solution,
after removing below tag, it worked.
<entityFramework>
<!--<defaultConnectionFactory type="System.Data.Entity.CrossCutting.SqlConnectionFactory, EntityFramework"/>-->
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
</providers>
</entityFramework>
guys, is this tag mandatory???
From my machine (.Net 4.0 installed), if I execute exe from different machine's (.Net 4.5.1 installed) shared folder, it throws error when exe's config has above tag. works if I remove the above tag.
If we execute the same exe in local machine (.Net 4.0), it works with or without above tag.
Upvotes: 1
Reputation: 2461
It sounds like the Microsoft .NET Framework 4 Client Profile is installed on the problem system. Installing the full framework on the client PC should resolve the issue.
The Microsoft .NET Framework 4 (full) version can be found here:
http://www.microsoft.com/en-us/download/details.aspx?id=17718
Upvotes: 1