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
Related
I am trying to implement enterprise library caching and logging.
I have the latest version (6.0.1304.0) of EnterpriseLibrary.Logging and EnterpriseLibrary.Common
I have the latest version (5.0.505.0) of EnterpriseLibrary.Caching
I am getting the below error when I create cache managerCacheManager cacheManager = (CacheManager)CacheFactory.GetCacheManager();
System.TypeLoadException
HResult=0x80131522
Message=Could not load type 'Microsoft.Practices.EnterpriseLibrary.Common.Configuration.EnterpriseLibraryContainer' from assembly 'Microsoft.Practices.EnterpriseLibrary.Common, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
Source=Microsoft.Practices.EnterpriseLibrary.Caching
Below is my web.config
<configSections>
<section name="cachingConfiguration"
type="Microsoft.Practices.EnterpriseLibrary.Caching.Configuration.CacheManagerSettings,
Microsoft.Practices.EnterpriseLibrary.Caching, Version=5.0.505.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
</configSections>
<cachingConfiguration defaultCacheManager="Default Cache Manager">
<cacheManagers>
<add name="Default Cache Manager" expirationPollFrequencyInSeconds="60"
maximumElementsInCacheBeforeScavenging="1000" numberToRemoveWhenScavenging="10"
backingStoreName="inMemory" type="Microsoft.Practices.EnterpriseLibrary.Caching.CacheManager,Microsoft.Practices.EnterpriseLibrary.Caching, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</cacheManagers>
<backingStores>
<add name="inMemory" type="Microsoft.Practices.EnterpriseLibrary.Caching.BackingStoreImplementations.NullBackingStore, Microsoft.Practices.EnterpriseLibrary.Caching, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</backingStores>
</cachingConfiguration>
According Microsoft Learn documentation (TypeLoadException Class), this type of exception occurs when the Assembly cannot be found by Common Languange Runtime; like documentation, please, check if the Solution library (DLL) reference point to a different version of Microsoft.Practices.EnterpriseLibrary based on the Web.Config, this maybe the root-cause.
I think its because both EnterpriseLibrary.Caching and EnterpriseLibrary.Logging both rely internally on EnterpriseLibrary.Common. As both have different versions used here, there is a version conflict for EnterpriseLibrary.Common. There is usually a backward compatibility but as you are trying to use different versions, it is trying to find version 6.0.1304.0 for EnterpriseLibrary.Common version instead of 5.0.xxx version somewhere internally. I think using 5.0.xxx versions for EnterpriseLibrary.Logging and EnterpriseLibrary.Common should ideally resolve the issue here.
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.
We are trying to create a WCF web service which will connect to SQL Server using Entity Framework. The WCF Service will be deployed on SharePoint 2013 mapped to ISAPI folder on SharePoint hive.
We are able to deploy the solution in SharePoint 2013 server, but whenever we call the web service it returns error as below
System.IO.FileNotFoundException: Could not load file or assembly
'EntityFramework, Version=6.0.0.0, Culture=neutral,
PublicKeyToken=XXXX' or one of its dependencies. The system cannot
find the file specified.\u000d\u000a File name: 'EntityFramework,
Version=6.0.0.0, Culture=neutral, PublicKeyToken=XXXX'\u000d\u000a
at ()\u000d\u000a at \u000d\u000a\u000d\u000a"
In App.Config file we have below code.
<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>
<configuration>
We created a simple console application on same SharePoint 2013 server and the code ran successfully.
What are we missing here?
The problem was that the entity framework DLL needed to be present in the GAC. Despite being present in the SharePoint solution, it was not referring to it.
We added entity framework DLLs to GAC and it has now started working.
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.