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.
Related
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.
I have the following warning messages during build.
No way to resolve conflict between "System.ComponentModel.Annotations,
Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and
"System.ComponentModel.Annotations, Version=4.0.10.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a". Choosing
"System.ComponentModel.Annotations, Version=4.1.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a" arbitrarily.
We have around 70 C# projects (net framework 462, net core, net standard). Are there any automated tools to fix the version conflicts problem?
As Power BI Embedded release to official version 1.0, I tried to upgrade PowerBI nuget packages in my application from version beta to 1.0, everything works perfectly on localhost.
But when I deploy to the web server (IIS on Windows Server 2012 R2), I got exception:
c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ada706e8\d6adc8aa\App_Web_index.cshtml.1c5a15dd.b_ofojaq.0.cs(77): error CS0012: The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
I am not sure how to fix it, my application on .NET 4.6.1. I had to go back beta version for production until finding the way to fix it.
It fixed by adding the line:
<add assembly="System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
into web.config:
<compilation debug="true" targetFramework="4.6.1">
<assemblies>
<add assembly="System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</assemblies>
....
</compilation>
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 have a ASP MVC Project which I didn't make but I need to upload it on a IIS server. This works but when I upload it and visit the website I get this error:
Could not load file or assembly 'Microsoft.VisualStudio.Web.PageInspector.Loader, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
Everything works locally but not on the server. Things I tried already:
Repairing .NET Framework
Trying to remove 2 lines from .NET Framework webconfig (Located in: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config) file but can't because file is in use. Can't stop process because of Access Denied error
I found that removing these 2 lines might be a solution but I can't remove them:
<remove assembly="Microsoft.VisualStudio.Web.PageInspector.Loader, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<add assembly="Microsoft.VisualStudio.Web.PageInspector.Loader, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
Is there something I am missing? Any help is much appreciated! Thx
Try adding just this line to your site web.config. The config files are inherited from the .NET base up to you site and then folders in your site. So Your site will override the .NET framework config.
<remove assembly="Microsoft.VisualStudio.Web.PageInspector.Loader, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
EDIT
The line should go here...
<configuration>
<system.web>
<compilation>
<assemblies>
<remove assembly="Microsoft.VisualStudio.Web.PageInspector.Loader, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</assemblies>
</compilation>
</system.web>
</configuration>
It should be noted that all that junk in the assembly attribute more than likely needs to be identical to the one that adds it in the .NET framework config.