We are receiving this error when calling a WCF .net 4.0 service using entity framework.
The 'DbProviderFactories' section can only appear once per config file
It is the first app on the server using EF and other .net 4.0 WCF services are not receiving this error.
Is there any way to correct this error with out editing the machine config file on the server?
The installation for IBM DB2 .NET provider, causes an empty DbProviderFactories, see below. Just delete the second empty entry DbProviderFactories
<system.data>
<DbProviderFactories>
<add name="IBM DB2 for i .NET Provider" invariant="IBM.Data.DB2.iSeries" description=".NET Framework Data Provider for IBM i" type="IBM.Data.DB2.iSeries.iDB2Factory, IBM.Data.DB2.iSeries, Version=12.0.0.0, Culture=neutral, PublicKeyToken=9cdb2ebfb1f93a26" />
</DbProviderFactories>
<DbProviderFactories />
</system.data>
Maybe you could create web.config entries which override any machine-wide settings you want changed.
Described here:
Override machine.config by web.config
Putting the <clear /> instruction inside of the DbProviderFactories tags in the web config to clear out and then override the duplicate entries made in the machine config. Thus doing a hack-work around of the error in the machine.config.
You have to update Machine.config file located in the below paths.
C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG\Machine.Config
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\Machine.Config
For 64-bit machines, Machine.config will be located in ...\Framework64\...
The block to pay attention to is this:
<system.data>
<DbProviderFactories>
<add name="IBM DB2 for i5/OS .NET Provider" invariant="IBM.Data.DB2.iSeries" description=".NET Framework Data Provider for i5/OS" type="IBM.Data.DB2.iSeries.iDB2Factory, IBM.Data.DB2.iSeries, Version=12.0.0.0, Culture=neutral, PublicKeyToken=9cdb2ebfb1f93a26"/>
<add name="Microsoft SQL Server Compact Data Provider" invariant="System.Data.SqlServerCe.3.5" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=3.5.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
</DbProviderFactories>
<!-- This is the line to remove - empty element --><DbProviderFactories/>
</system.data>
As #yonsk already mentioned why this problem occurs (duplicate entry of ), you can create a console application which can fix the machine.config file and then, invoke that console application from your Application's Installer or from your Application whenever you get the Exception. The following code can be used for the console application that will fix the machine.config file.
class Program
{
static void Main()
{
string machineConfigFilePath = RuntimeEnvironment.SystemConfigurationFile;
XDocument xdoc = XDocument.Load(machineConfigFilePath);
XElement[] elements = xdoc.XPathSelectElements("//configuration/system.data/DbProviderFactories").ToArray();
if (elements.Any())
{
foreach (XElement anElement in elements)
{
if (!anElement.HasElements)
anElement.Remove();
}
}
xdoc.Save(machineConfigFilePath);
}
}
If you want to call the console application, from your Application, you would need to invoke that as Administrator. So, the following snippet may help to invoke that console application as Administrator (The user will be prompted with a dialog to accept..)
try
{
Process process = Process.Start(new ProcessStartInfo
{
Verb = "runas",
FileName = "/Path/to/the/console/application",
UseShellExecute = true,
CreateNoWindow = true,
});
process.WaitForExit();
int exitCode = process.ExitCode;
}
catch (Exception ex)
{
}
Related
I'm having some issues with SignalR 2.0 in EPiServer 7.5 (a MVC4 framework). All I get is a 404 error
GET http://web.com/signalr/hubs 404 (Not Found)
I'm hosting everything on a Windows 2012 R2 Server. Also noteworthy is that the solution works when running everything in IIS Express from Visual Studio but not in IIS 8.5.
What I've done so far is to add the SingalR references.
Microsoft.AspNet.SignalR.Client, 2.0.0.0
Microsoft.AspNet.SignalR.Core, 2.0.0.0
Microsoft.AspNet.SignalR.System.Web, 2.0.0.0
Microsoft.OWin, 2.1.0.0
Microsoft.OWin.Host.SystemWeb, 2.1.0.0
Microsoft.Owin.Security, 2.0.0.0
Owin, 1.0.0.0
Startup.cs
The startup is intitialized on application start so that seems to work.
[assembly: OwinStartup(typeof(Web.Startup))]
namespace Web
{
public class Startup
{
#region Local variables
private static readonly ILog Logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Methods
/// <summary>
/// Configure SignalR
/// </summary>
/// <param name="app"></param>
public void Configuration(IAppBuilder app)
{
try
{
Logger.MethodCallEntry();
// Any connection or hub wire up and configuration should go here
//app.MapSignalR(); // Doesn't work either
var hubConfiguration = new HubConfiguration
{
EnableDetailedErrors = true,
EnableJavaScriptProxies = false
};
app.MapSignalR("/signalr", hubConfiguration);
}
catch (Exception ex)
{
Logger.Error("Failed to initialize or map SignalR", ex);
}
finally
{
Logger.MethodCallExit();
}
}
#endregion
}
}
Script inclusion
<script src="/Static/Frameworks/Scripts/jquery-1.10.2.js"></script>
<script src="/Static/Frameworks/Scripts/knockout-3.0.0.js"></script>
<script src="/Static/Frameworks/Scripts/modernizr.2.7.0.js"></script>
<script src="/Static/Frameworks/Scripts/jquery.signalR-2.0.1.js"></script>
<!-- also tried path ~/signalr/hubs -->
<script src="/signalr/hubs"></script>
This is not a solution updated from 1.x SignalR!
just wanted to put my 2 cents in. I had this error, and it ended up being because i had
<add key="owin:AutomaticAppStartup" value="false" />
in my web.config. removing this line fixed everything up for me!
The error was the exact same as in this post
http://blogs.msdn.com/b/praburaj/archive/2013/12/02/owin-startup-class-not-detected.aspx
The solution was to totally empty the asp.net cache
Run this in PowerShell
net stop w3svc
Remove-Item -Path "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\*" -Force -Recurse
Remove-Item -Path "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\*" -Force -Recurse
net start w3svc
I just had a similar problem getting the "MoveShape" demo to work on a freshly built Win 2012R2 server. I resolved the problem by adding the role/features: "Web Server (IIS)" -> "Application Development" and selecting ".NET Extensibility 4.5", "ASP.NET 4.5", "ISAPI Extensions", "ISAPI Filters" and "WebSocket Protocol".
Once I restarted the system or IIS, the demo starting working.
My problem was resolved by removing nuget-package "Microsoft.Owin.Host.SystemWeb", which was referenced in packages.config with version="2.1.0" and installing version="3.0.1".
With this version the owin environment was never started on the iis8 on server 2012r2 with the error, that the namespace "Host" was not found.
Microsoft.Common.CurrentVersion.targets(1697,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.Owin.Host.SystemWeb, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL". Check to make sure the assembly exists on disk.
Startup.cs(2,22): error CS0234: The type or namespace name 'Host' does not exist in the namespace 'Microsoft.Owin' (are you missing an assembly reference?) [*.csproj]
Just had the same 404 problem. Ended up I updated all the DLLs except for one which was problem. I didn't update Microsoft.AspNet.SignalR.SystemWeb.dll
I have a .NET Web solution with an Azure Cloud Service project and a single webrole. I deploy it to the East coast West coast data/compute centers for failover purposes and have been asked to automate the deployment using Powershell MSBuild and Jenkins.
The problem is i need to change the Sql Azure database connectionString in the Web.config prior to packaging and publishing to each deployment. Seems simple enough.
I understand that the webrole properties Settings tab allows you to add custom configuration properties to each deployment with a type of either "string" or "Connection String" but it looks like the "Connection String" option applies to only Blob, Table or Queue storage. If I use the "String" and give it an Sql Azure connection string type it writes it out as an key/value pair and Entity Framework and the Membership Provider do not find it.
Is there a way to add a per-deployment connection string setting that points to Sql Azure?
Thanks,
David
Erick's solution is completely valid and I found an additional way to solve the problem so I thought I'd come back and put it up here since I had such trouble finding an answer.
The trick is getting the Entity Framework and any providers like asp.net Membership/profile/session etc... to read the connection string directly from the Azure service configuration rather than the sites web.config file.
For the providers I was able to create classes that inherit the System.Web.Providers.DefaultMembershipProvider class and override the Initialize() method where I then used a helper class I wrote to retrieve the connection string using the RoleEnvironment.GetConfigurationSettingValue(settingName); call, which reads from the Azure service config.
I then tell the Membership provider to use my class rather than the DefaultMembershipProvider. Here is the code:
Web.config:
<membership defaultProvider="AzureMembershipProvider">
<providers>
<add name="AzureMembershipProvider" type="clientspace.ServiceConfig.AzureMembershipProvider" connectionStringName="ClientspaceDbContext" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
</providers>
Note the custom provider "AzuremembershipProvider"
AzuremembershipProvider class:
public class AzureMembershipProvider : System.Web.Providers.DefaultMembershipProvider
{
public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
{
string connectionStringName = config["connectionStringName"];
AzureProvidersHelper.UpdateConnectionString(connectionStringName, AzureProvidersHelper.GetRoleEnvironmentSetting(connectionStringName),
AzureProvidersHelper.GetRoleEnvironmentSetting(connectionStringName + "ProviderName"));
base.Initialize(name, config);
}
}
And here's the helper class AzureProvidersHelper.cs:
public static class AzureProvidersHelper
{
internal static string GetRoleEnvironmentSetting(string settingName)
{
try
{
return RoleEnvironment.GetConfigurationSettingValue(settingName);
}
catch
{
throw new ConfigurationErrorsException(String.Format("Unable to find setting in ServiceConfiguration.cscfg: {0}", settingName));
}
}
private static void SetConnectionStringsReadOnly(bool isReadOnly)
{
var fieldInfo = typeof (ConfigurationElementCollection).GetField("bReadOnly", BindingFlags.Instance | BindingFlags.NonPublic);
if (
fieldInfo != null)
fieldInfo.SetValue(ConfigurationManager.ConnectionStrings, isReadOnly);
}
private static readonly object ConnectionStringLock = new object();
internal static void UpdateConnectionString(string name, string connectionString, string providerName)
{
SetConnectionStringsReadOnly(false);
lock (ConnectionStringLock)
{
ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings["name"];
if (connectionStringSettings != null)
{
connectionStringSettings.ConnectionString = connectionString;
connectionStringSettings.ProviderName = providerName;
}
else
{
ConfigurationManager.ConnectionStrings.Add(new ConnectionStringSettings(name, connectionString, providerName));
}
}
SetConnectionStringsReadOnly(true);
}
}
The key here is that the RoleEnvironment.GetConfigurationSettingValue reads from the Azure service configuration and not the web.config.
For the Entity Framework that does not specify a provider I had to add this call to the Global.asax once again using the GetRoleEnvironmentSetting() method from the helper class:
var connString = AzureProvidersHelper.GetRoleEnvironmentSetting("ClientspaceDbContext");
Database.DefaultConnectionFactory = new SqlConnectionFactory(connString);
The nice thing about this solution is that you do not end up having to deal with the Azure role onstart event.
Enjoy
dnash
David,
A good option is to use the Azure configurations. If you right click on the Azure project, you can add an additional configuration. Put your connection string(s) in the correct configuration (e.g., ServiceConfiguration.WestCoast.cscfg, ServiceConfiguration.EastCoast.cscfg, etc).
In your build script, pass the TargetProfile property to MSBuild with the name of the configuration, and those settings will be built into the final cscfg.
Let me know if you run into any problems. I did the approach, and it took a few tries to get it working right. Some details that might help.
Erick
Situation
I have a client library that uses the Windows Azure AppFabric Service Bus NetTcpRelayBinding to connect to the endpoint. The client library is hosted by an application, that is not necessarily a .NET-application. Anyway, app.config is out of the question, which means everything should be configured in code.
Machine.config is one option, but it's better if it can be avoided. A local custom proxy or a front-end server could be another option, but I'd like to explore this option first, before changing architecture that radically.
There are no problems with system bindings, but I haven't figured out or found a solution how to add the following configuration to a ChannelFactory in code:
<extensions>
<bindingElementExtensions>
<add name="tcpRelayTransport" type="Microsoft.ServiceBus.Configuration.TcpRelayTransportElement, Microsoft.ServiceBus, Version=1.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</bindingElementExtensions>
<bindingExtensions>
<add name="netTcpRelayBinding" type="Microsoft.ServiceBus.Configuration.NetTcpRelayBindingCollectionElement, Microsoft.ServiceBus, Version=1.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</bindingExtensions>
</extensions>
Here is the solution that has now been tested. Hopefully it makes clear, what the problem really was and maybe it helps somebody else with a similar problem. Credits to co-worker, who had the time to investigate the issue.
The solution was to edit dynamically the configuration and add the reference to the required Binding Element Extensions (without app.config in any layer or without changing machine.config in client machines):
var service = ServiceModelSectionGroup.GetSectionGroup(ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None));
var tcpRelayTransportExtension = new ExtensionElement("tcpRelayTransport", "Microsoft.ServiceBus.Configuration.TcpRelayTransportElement, Microsoft.ServiceBus, Version=1.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
var netTcpRelayTransportExtension = new ExtensionElement("netTcpRelayBinding", "Microsoft.ServiceBus.Configuration.NetTcpRelayBindingCollectionElement, Microsoft.ServiceBus, Version=1.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
if (service.Extensions.BindingElementExtensions.ContainsKey(tcpRelayTransportExtension.Name) == false)
{
service.Extensions.BindingElementExtensions.Add(tcpRelayTransportExtension);
}
if (service.Extensions.BindingElementExtensions.ContainsKey(netTcpRelayTransportExtension.Name) == false)
{
service.Extensions.BindingElementExtensions.Add(netTcpRelayTransportExtension);
}
Thanks to everyone who tried to help, though!
You can add the binding element extension via code by writing a custom service host factory. A similar question has been answered here
Based on your type of WCF service you just need to inherit the appropriate servicehostfactory class when writing a custom service host factory. For example as shown below:
How to build a custom service host
If building a REST WCF Service use WebServiceHostFactory
If building a WCF service use ServiceHostFactory
A sample for this without config is available here: http://code.msdn.microsoft.com/windowsazure/Relayed-Messaging-Windows-0d2cede3
Following is the code snippet:
ChannelFactory<IEchoChannel> channelFactory = null;
IEchoChannel channel = null;
try
{
//Create a Behavior for the Credentials
TransportClientEndpointBehavior sharedSecretServiceBusCredential = new TransportClientEndpointBehavior();
sharedSecretServiceBusCredential.TokenProvider = TokenProvider.CreateSharedSecretTokenProvider(issuerName, issuerSecret);
//Create a Channel Factory
channelFactory = new ChannelFactory<IEchoChannel>(new NetTcpRelayBinding(), new EndpointAddress(serviceAddress));
channelFactory.Endpoint.Behaviors.Add(sharedSecretServiceBusCredential);
LogMessage("Opening channel to: {0}", serviceAddress);
channel = channelFactory.CreateChannel();
channel.Open();
LogMessage("Sending: {0}", echoTextBox.Text);
string echoedText = channel.Echo(echoTextBox.Text);
LogMessage("Received: {0}", echoedText);
echoTextBox.Text = string.Empty;
LogMessage("Closing channel");
channel.Close();
LogMessage("Closing factory");
channelFactory.Close();
}
catch (Exception ex)
{
LogMessage("Error sending: {0}<br/>{1}", ex.Message, ex.StackTrace.Replace("\n", "<br/>"));
// Close the channel and factory properly
if (channel != null)
{
CloseCommunicationObject(channel);
}
if (channelFactory != null)
{
CloseCommunicationObject(channelFactory);
}
}
I am updating this post with what I think I now know about getting this configuration; HOWEVER, there is more to know as I am still having a problem is one crucial area.
I use SQLite for unit testing, which now works fine, using the configuration steps below. I also use it when I want a test run of the UI with more data than in-memory test data but without the overhead of SQLServer - this configuration fails with the following:
{"Could not create the driver from NHibernate.Driver.SQLite20Driver, NHibernate, Version=2.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4."}
Here is updated info on configs that DO work:
1) Which SQLite dll?? There are some bad links out there that look helpful but that have build errors in them. The only good download as of this date is here at Source Forge. v1.066 which was released today, 4-18-2010.
2) Must you use the GAC? No, as answered by Mauricio.
3) x64 builds - as answered by Mauricio.
4) NHib driver - SQLite20Driver, as answered by Mauricio
5) FNH as a potential conflict - no, as answered by Mauricio
Cheers,
Berryl
== ADD'L DEBUG INFO ===
When the exception is hit and I call up the SQLite20Drive assembly, I get the following which suggests to me that the driver should be available. I am wondering though, as the configuration code is in a different assembly.
-- assembly when error ----
?typeof(SQLite20Driver).Assembly
{NHibernate, Version=2.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4}
[System.Reflection.RuntimeAssembly]: {NHibernate, Version=2.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4}
CodeBase: "file:///C:/Users/Lord & Master/Documents/Projects/Smack/trunk/src/ConstructionAdmin.WpfPresentation/bin/Debug/NHibernate.DLL"
EntryPoint: null
EscapedCodeBase: "file:///C:/Users/Lord%20%26%20Master/Documents/Projects/Smack/trunk/src/ConstructionAdmin.WpfPresentation/bin/Debug/NHibernate.DLL"
Evidence: {System.Security.Policy.Evidence}
FullName: "NHibernate, Version=2.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4"
GlobalAssemblyCache: false
HostContext: 0
ImageRuntimeVersion: "v2.0.50727"
IsDynamic: false
IsFullyTrusted: true
Location: "C:\\Users\\Lord & Master\\Documents\\Projects\\Smack\\trunk\\src\\ConstructionAdmin.WpfPresentation\\bin\\Debug\\NHibernate.dll"
ManifestModule: {NHibernate.dll}
PermissionSet: {<PermissionSet class="System.Security.PermissionSet"
version="1"
Unrestricted="true"/>
}
ReflectionOnly: false
SecurityRuleSet: Level1
--- assembly when unit testing (NO ERROR)
{NHibernate, Version=2.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4}
[System.Reflection.RuntimeAssembly]: {NHibernate, Version=2.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4}
CodeBase: "file:///C:/Users/Lord & Master/Documents/Projects/Smack/trunk/src/ConstructionAdmin.Tests/bin/Debug/NHibernate.DLL"
EntryPoint: null
EscapedCodeBase: "file:///C:/Users/Lord%20%26%20Master/Documents/Projects/Smack/trunk/src/ConstructionAdmin.Tests/bin/Debug/NHibernate.DLL"
Evidence: {System.Security.Policy.Evidence}
FullName: "NHibernate, Version=2.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4"
GlobalAssemblyCache: false
HostContext: 0
ImageRuntimeVersion: "v2.0.50727"
IsDynamic: false
IsFullyTrusted: true
Location: "C:\\Users\\Lord & Master\\Documents\\Projects\\Smack\\trunk\\src\\ConstructionAdmin.Tests\\bin\\Debug\\NHibernate.dll"
ManifestModule: {NHibernate.dll}
PermissionSet: {<PermissionSet class="System.Security.PermissionSet"
version="1"
Unrestricted="true"/>
}
ReflectionOnly: false
SecurityRuleSet: Level1
Here is the bootstrapper for this a SQLite session:
/// <summary>SQLite-NHibernate bootstrapper for general use.</summary>
public class SQLiteBoot : IDisposable
{
public readonly ISessionFactory SessionFactory;
private readonly ISession _session;
private static Configuration _config;
private static string _persistenceModelGeneratorName;
public SQLiteBoot(IAutoPersistenceModelGenerator persistenceModelGenerator) {
if (_isSessionFactoryBuildRequired(persistenceModelGenerator)) {
_config = new Configuration()
.SetProperty(ENV.ReleaseConnections, "on_close")
.SetProperty(ENV.Dialect, typeof (SQLiteDialect).AssemblyQualifiedName)
.SetProperty(ENV.ConnectionDriver, typeof (SQLite20Driver).AssemblyQualifiedName)
.SetProperty(ENV.ConnectionString, "data source=:memory:")
.SetProperty(ENV.ProxyFactoryFactoryClass, typeof (ProxyFactoryFactory).AssemblyQualifiedName)
.SetProperty(ENV.CurrentSessionContextClass, typeof (ThreadStaticSessionContext).AssemblyQualifiedName);
_persistenceModelGeneratorName = persistenceModelGenerator.Name;
var persistenceModel = persistenceModelGenerator.Generate();
var fluentCfg = Fluently.Configure(_config).Mappings(m => m.AutoMappings.Add(persistenceModel));
SessionFactory = fluentCfg.BuildSessionFactory();
Check.Require(SessionFactory.GetAllClassMetadata().Count > 0, "No mapped classes - check your AutoPersistenceModel!");
}
_session = SessionFactory.OpenSession();
CurrentSessionContext.Bind(_session);
new SchemaExport(_config).Execute(true, true, false, _session.Connection, Console.Out);
}
private bool _isSessionFactoryBuildRequired(IAutoPersistenceModelGenerator persistenceModelGenerator)
{
return
_config == null
|| SessionFactory == null
|| !persistenceModelGenerator.Name.Equals(_persistenceModelGeneratorName);
}
public void Dispose()
{
_session.Dispose();
}
}
}
Sure. You can also use previous versions if you configure mixed mode loading.
No need to be in the GAC. You can use gacutil to remove the assemblies from the GAC.
Use the x64 DLL to target Windows x64 and x86 for Windows x86
Please post the full exception stack trace. Also if you're using a 3.5 assembly use mixed mode loading.
FNH has no reference to SQLite.
I want this to stand out so it will help someone else; the full reason this happens is explained here; so adjust your congig to use BOTH the redirect there in combo with the mixed loading mode referenced here by Mauricio.
I had the same problem, and found little or no help on all the forum and blog posts.
Note that this problem is specific to a case respecting all of the following criteria:
- using SQLite
- with System.Data.SqlLite
- on an x64 machine
- and NHibernate (2.1.2.4 in my case)
That chunk of config in my web.config (or app.config for my unit tests) got it to work. I had to qualify the assembly to be sure he loads correctly.
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<qualifyAssembly
partialName="System.Data.SQLite"
fullName="System.Data.SQLite, Version=1.0.66.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=AMD64" />
</assemblyBinding>
</runtime>
</configuration>
Somewhere in it's inner plumbing, during the mapping using scanned assemblies, NHibernate creates an Assembly object using it's paritla name, as a string, "System.Data.SQLite". Somehow, the x86 version of the assembly got loaded.
The above configuration made sure that using the partial name to load an assembly would provide the x64 version.
EDIT: I use version 1.0.66.0 and took the DLL under the bin\x64 folder in the file SQLite-1.0.66.0-binaries.zip available on sourceforge here.
I have a web deployment project that does a web.config section replacement using an external file. (this is to change the connection strings section).
The web.config section replacement works fine when built manually, but when built as part of a TFS build the section is not replaced. I cannot find any errors or warnings in the build log.
What are the likely causes, or how can I 'debug' this?
Have you considered using Web.Config's ability to pull a section from a separate file? You refer to the external file like so (this is my code for loading a file that has my connection strings section):
<connectionStrings configSource="WebCS.config"/>
Then the connection string can be deployed as a separate file:
<connectionStrings>
<add name="ConnString" connectionString="Data Source=<server>;Initial Catalog=<DB>;User ID=<ID>;Password=<pwd>" providerName="System.Data.SqlClient"/>
</connectionStrings>
That way, you don't have to worry about changing the web.config file at all.
I am not sure this will help at all....but this is a way to add/update a connection string without having to replace the whole config section.
public static void SaveConfigVal(string connectionString, string connName)
{
System.Configuration.ExeConfigurationFileMap fileMap = new System.Configuration.ExeConfigurationFileMap();
fileMap.ExeConfigFilename = GetConfigFileName();
//System.Configuration.Configuration config = System.Configuration.ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
System.Configuration.Configuration config = System.Configuration.ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);
// Retrieve the section group
ConnectionStringSettings keyValue = config.ConnectionStrings.ConnectionStrings[connName];
// If the key already exists, just replace
if (keyValue != null)
{
keyValue.ConnectionString = connectionString;
}
else
{
// Add a new key if the setting doesn't exist
config.ConnectionStrings.ConnectionStrings.Add(new ConnectionStringSettings(connName, connectionString));
}
config.Save(ConfigurationSaveMode.Modified);// (ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection("ConnectionStrings");
}
private static string GetConfigFileName()
{
//return config file name....
}
If you're using or can upgrade to Visual Studio 2010, you can utilize the new web.config transformations to alter the web.config based on selected configuration.
http://msdn.microsoft.com/en-us/library/dd465318.aspx