I have a project that is set up as a shell extension with a SharpShell
library. When I register it with regasm
tool (with /codebase
flag on) it works up until the point where I need to use the database via EntityNetwork
. I get this error:
No connection string named 'EntitiesName' could be found in the application config file.
But of course I have the correct ConnectionString
in the config
file. It appears the whole config
file is not being read at all.
So then I found a kind of a hack solution, I put this in the constructor:
Dim assemblyLoc As String = [GetType].Assembly.Location
Dim configName As String = assemblyLoc + ".config"
AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE", configName)
and it appears something IS read, but not everything, I get a new error:
System.TypeInitializationException: The type initializer for 'System.Data.Entity.Internal.AppConfig' threw an exception. ---> System.Configuration.ConfigurationErrorsException: An error occurred creating the configuration section handler for entityFramework: Could not load file or assembly 'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified.
How can I use a config file or how can I use the EntityFramework
with this kind of setup?
This is how my config
file looks like:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<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="EntitiesName" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string="***"" providerName="System.Data.EntityClient" />
</connectionStrings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</configuration>
I suspect I might need to use Code-based configuration. If that's the case, I'd appreciate some vb.net
pointers in that direction.