We use app.config to store user settings, but changed the name of the exe... for reasons. I need to be able to upgrade the settings from version 1.4 called name1.exe to version 1.5 now called name2.exe.
I've tried several methods, the first was to add code in Program.cs Main() where it would use System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.PerUserRoamingAndLocal).FilePath to find the path where the new settings file should go, and search the base path of that setting to find the 1.4 version under the old name, then copy the 1.4 folder into the correct part of the path where the Properties.Settings.Default.Upgrade() would work like normal.
I've also tried replacing the new app.config file with the old one and calling Properties.Settings.Default.Reload(); and doing the same but just restarting the application.
Each of those methods worked, even in release mode outside the ide. But we also use SmartAssembly to merge some other dlls into our exe's assembly. Smart assembly must do some unknown magic, because it doesn't work after being SmartAssembled.
If I manually copy the old settings to the new location (replacing the app.config) then try to run my app doens't even start, it must crash right away. Again, only after using SmartAssembly to merge our dlls. I've narrowed the crashing down to this part in the xml...
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="userSettings">
<section name="DllNameA.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="DllNameB.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="ExeName.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
That last part of the xml "section name=ExeName.Properties.Settings..."
was not there in the old settings file. I'm not sure why it's added now, but it works if I manually add it to the old settings file when copying it over.
Is there a way to make this work?
This probably isn't the right way to do this, but I did just edit the xml to add the missing section and it is working.
Related
We've got a new WPF app we've written, that doesn't get any further than the landing screen. Once a user clicks on a button to do something they're confronted with an error that reads like this:
An Error occurred:Set property
'System.Windows.ResourceDictionary.Source' threw an exception.
System.IO.FileNotFoundException: Could not load file or assembly
'BEMR, Culture=neutral' or one of its dependencies. The system cannot
find the file specified.
(Our app is named BEMR.)
Yes, there is no file by that name. I searched throughout the whole project and besides the string "BEMR, Culture=neutral" being in EF's EDMX files, the only other place that string appears is in the App.Config file:
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
It most certainly is not a file, just a reference to the culture that EF is using.
So, what is causing our app to try and find a file by that name?
I added a app config file to C# project and wanted to store config for log4Net and some basic app setting. The generated app.config file is empty.
I looked at other projects. They had an applicationSettings section. So I added a applicationSettings section; by copy pasting from some other project. Then I did not understand what some of the attributes were; like the PublicKeyToken b77a5c561934e089. I tried searching to see if the section is automatically generated; could not find how. The online resources point to complicated schemes about writing your own config class. My needs are far simple. Online resources do not document the attributes per se.
So short of copy pasting from some other project, how do you get around to adding this section?
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="CrawlReponseHandler.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</sectionGroup>
The section is added automatically by going to project -> properties -> settings tab and adding the properties.
I would like to be able to step into Entity Frameworks source code and make some local edits to the source code for testing only.
I know I could enable the symbols and step into the code but I need to be able to make some edits to see if I can fix a bug in the code for SQL Geography.
When I download the source and include the projects in my solution, I received the "strong key" error.
So I removed the signed keys but now I am getting another error.
Could not load file or assembly 'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)":"EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
This leads me to believe that it can't find the DLL in my bin folder or that there is some assembly resolver that is not reading my bin first.
Is there any "easy" way to debug / edit Entity Framework source code locally?
Well the answer was very easy.
In the .config file I changed this
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
To this
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral" requirePermission="false" />
Basically removing the PublicKeyToken fixed the issue.
.Net assembly PublicKeyToken
I am working on a web app(Asp.Net) and need to draw a chart which is using data from database.
In debug mode, I can retrieve data from database but when try to add chart
chart proporties-> dataSourceId -> SqlDataSource..
connectionstring is ok
Then I get this
The data provide 'FirebirdSql.Data.Firebird.Client' could not be found in the system configuration. unable to find the requested .NetFramework Data Provider. it may not be installed.
Why I am getting this and how to fix it?
Thanks.
This is most probably to do with the version of Firebird. Check your machine.config file for these lines:
Wrong:
<configSections>
<section name="FirebirdSql.Data.FirebirdClient" type="System.Data.Common.DbProviderConfigurationHandler, System.Data, Version=2.6.5.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</configSections>
What it should be:
<configSections>
<section name="firebirdsql.data.firebirdclient" type="System.Data.Common.DbProviderConfigurationHandler, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</configSections>
Your machine.config file can be found at these locations (x86 or x64):
32-bit
x:\Windows\Microsoft.NET\Framework\[version]\config\machine.config
64-bit
x:\Windows\Microsoft.NET\Framework64\[version]\config\machine.config
I think you only need to edit the 32 bit version of the machine.config file as VS 2010 is 32-bit only I believe.
Try these things first and hopefully you'll find a fix!
EDIT; try reinstalling Firebird, download the latest version and uninstall all instances of Firebird from your computer beforehand
http://www.firebirdsql.org/en/net-provider/
Hello when I try to add parameters to the settings table
I get multiple messages for each parameter I add.
e.g.:
Could not find schema information for
the element 'userSettings'
Could not find schema information for
the element 'setting'
Could not find schema information for
the attribute 'serializeAs'
In the app.config I get:
<project1.Properties.Settings>
<setting name="ccc" serializeAs="String">
<value>vvv</value>
</setting>
</project1.Properties.Settings>
I can use, edit and save this parameter, but the messages really annoy me.
I use the following schema (and selecting other like 20 and 30 did not help):
C:\Program Files (x86)\Microsoft Visual Studio 9.0\xml\Schemas\DotNetConfig.xsd
Any ideas?
edit:
following Hans post here is my configSections
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="project1.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
I don't know what it is for and if I should change it - yet here it is :)
Thanks Asaf
Well, that doesn't look healthy. Note how it is not valid XML, the project... element is mismatched with RuthSiteManager...
Not sure how it got that way, you'll have to edit it into shape. I guess you want to rename "project1". Avoid editing the .config file by hand otherwise. And make sure you have the required <configSections> element as well.
I just had this same issue. The fix I came across was to do a 'Clean Solution' followed by a 'Rebuild Solution'. This seems to rebuild the files correctly.