I have tried to create a project that implements the MySQL entity framework. I have added the EntityFramework, MySql.Data, and MySQL.Data.Entities NuGet packages. I also have the mysql-connector-net-6.7.4 installed. I have tried deleting and removing all of these things, but I still get the error below. I have added it as a server in the project and have been able to hit the db and pull down the test_table. I have used the MySQL connection and been able to connect to the db through visual studio. I keep getting this error though.
It fails on the last line of the code below context.test_table.Add(cookie).
sql123456Entities context = new sql123456Entities();
test_table cookie = new test_table
{
this_is_cool = "Yes it is",
this_is_cooler = 32,
but_is_it_the_fonz = "Yeah!"
};
context.test_table.Add(cookie);
Exception message (inner exception is null)
{"Could not load file or assembly 'MySql.Data, Version=6.6.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)":"MySql.Data, Version=6.6.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"}
Stack Trace:
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type)
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName)
at System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)
at System.Type.GetType(String typeName)
at System.Data.Common.DbProviderFactories.GetFactory(DataRow providerRow)
at System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName)
at System.Data.Entity.Infrastructure.DependencyResolution.DefaultProviderFactoryResolver.GetService(Type type, Object key, Func`3 handleFailedLookup)
at System.Data.Entity.Infrastructure.DependencyResolution.DefaultProviderFactoryResolver.GetService(Type type, Object key)
at System.Data.Entity.Infrastructure.DependencyResolution.CachingDependencyResolver.<>c__DisplayClass1.<GetService>b__0(Tuple`2 k)
at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
at System.Data.Entity.Infrastructure.DependencyResolution.CachingDependencyResolver.GetService(Type type, Object key)
at System.Data.Entity.Infrastructure.DependencyResolution.ResolverChain.<>c__DisplayClass3.<GetService>b__0(IDbDependencyResolver r)
at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
at System.Data.Entity.Infrastructure.DependencyResolution.ResolverChain.GetService(Type type, Object key)
at System.Data.Entity.Infrastructure.DependencyResolution.RootDependencyResolver.GetService(Type type, Object key)
at System.Data.Entity.Core.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString)
at System.Data.Entity.Core.EntityClient.EntityConnection..ctor(String connectionString)
at System.Data.Entity.Internal.LazyInternalConnection.InitializeFromConnectionStringSetting(ConnectionStringSettings appConfigConnection)
at System.Data.Entity.Internal.LazyInternalConnection.TryInitializeFromAppConfig(String name, AppConfig config)
at System.Data.Entity.Internal.LazyInternalConnection.Initialize()
at System.Data.Entity.Internal.LazyInternalConnection.CreateObjectContextFromConnectionModel()
at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
at System.Data.Entity.Internal.InternalContext.Initialize()
at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)
at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()
at System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext()
at System.Data.Entity.Internal.Linq.InternalSet`1.ActOnSet(Action action, EntityState newState, Object entity, String methodName)
at System.Data.Entity.Internal.Linq.InternalSet`1.Add(Object entity)
at System.Data.Entity.DbSet`1.Add(TEntity entity)
at ConsoleApplication2.Program.Main(String[] args) in c:\Users\recursor\Documents\Visual Studio 2012\Projects\CS3280\Final Project\IR\ConsoleApplication2\Program.cs:line 24
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
It looks like there were errors in the app.config. Under runtime there were dependent assemblies with binding re-directs that were improper. I had to be running EF5 because that is the last version of EF that MySQL supports. So I had to change the EF binding to this:
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
Related
I'm working with quite a complicated environment:
There are two main executables: <Application_Server>.exe and <Application>.Desktop.exe, a server application and a client application. Both applications are not to be modified.
In order to add functionality, DLL files can be added in the Modules subdirectory of both server and client runtime directories.
Last week, I had started up a client application, and now this seems not to work anymore. This would be due to the lack of the Telerik.OpenAccess.35.Extensions.dll, but this makes not sense: last week I also did not have that file in my runtime directory and still everything was working fine.
Can you find out where I should look in order to understand why my application now is asking to that Telerik related file?
This is my NLog-based output file:
2022-06-13 09:13:22.0707 | Application_Client.Desktop.App | Uncaught exception in MainWindow. --- System.IO.FileNotFoundException: Could not load file or assembly 'Telerik.OpenAccess.35.Extensions, Version=2016.2.822.1, Culture=neutral, PublicKeyToken=7ce17eeaf1d59342' or one of its dependencies. The system cannot find the file specified.
File name: 'Telerik.OpenAccess.35.Extensions, Version=2016.2.822.1, Culture=neutral, PublicKeyToken=7ce17eeaf1d59342' ---> System.IO.FileNotFoundException: Could not load file or assembly 'Telerik.OpenAccess.35.Extensions, Version=2016.2.822.1, Culture=neutral, PublicKeyToken=7ce17eeaf1d59342' or one of its dependencies. The system cannot find the file specified.
File name: 'Telerik.OpenAccess.35.Extensions, Version=2016.2.822.1, Culture=neutral, PublicKeyToken=7ce17eeaf1d59342'
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection)
at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.ReflectionOnlyLoad(String assemblyString)
at Prism.Modularity.DirectoryModuleCatalog.InnerModuleInfoLoader.OnReflectionOnlyResolve(ResolveEventArgs args, DirectoryInfo directory)
at System.AppDomain.OnReflectionOnlyAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName)
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable C:\<Runtime_Directory>\Application_Desktop.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = Telerik.OpenAccess.35.Extensions, Version=2016.2.822.1, Culture=neutral, PublicKeyToken=7ce17eeaf1d59342
(Fully-specified)
LOG: Appbase = file:///C:/<Runtime_Directory>/
LOG: Initial PrivatePath = NULL
Calling assembly : (Unknown).
===
LOG: This is an inspection only bind.
LOG: Using application configuration file: C:\<Runtime_Directory>\Application_Desktop.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Attempting download of new URL file:///C:/<Runtime_Directory>/Telerik.OpenAccess.35.Extensions.DLL.
LOG: Attempting download of new URL file:///C:/<Runtime_Directory>/Telerik.OpenAccess.35.Extensions/Telerik.OpenAccess.35.Extensions.DLL.
LOG: Attempting download of new URL file:///C:/<Runtime_Directory>/Modules/Telerik.OpenAccess.35.Extensions.DLL.
LOG: Attempting download of new URL file:///C:/<Runtime_Directory>/Modules/Telerik.OpenAccess.35.Extensions/Telerik.OpenAccess.35.Extensions.DLL.
LOG: Attempting download of new URL file:///C:/<Runtime_Directory>/Telerik.OpenAccess.35.Extensions.EXE.
LOG: Attempting download of new URL file:///C:/<Runtime_Directory>/Telerik.OpenAccess.35.Extensions/Telerik.OpenAccess.35.Extensions.EXE.
LOG: Attempting download of new URL file:///C:/<Runtime_Directory>/Modules/Telerik.OpenAccess.35.Extensions.EXE.
LOG: Attempting download of new URL file:///C:/<Runtime_Directory>/Modules/Telerik.OpenAccess.35.Extensions/Telerik.OpenAccess.35.Extensions.EXE.
at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)
at System.Reflection.RuntimeAssembly.GetExportedTypes()
at Prism.Modularity.DirectoryModuleCatalog.InnerModuleInfoLoader.<>c__DisplayClass1_0.<GetNotAllreadyLoadedModuleInfos>b__2(FileInfo file)
at System.Linq.Enumerable.<SelectManyIterator>d__17`2.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at Prism.Modularity.DirectoryModuleCatalog.InnerModuleInfoLoader.GetModuleInfos(String path)
at Prism.Modularity.DirectoryModuleCatalog.InnerModuleInfoLoader.GetModuleInfos(String path)
at Prism.Modularity.DirectoryModuleCatalog.InnerLoad()
at Prism.Modularity.ModuleCatalog.Initialize()
at Prism.Modularity.ModuleManager.Run()
at Application_Client.Desktop.Bootstrapper.InitializeModules() in D:\a\1\s\Application_Client.Desktop\Bootstrapper.cs:line 73
at Prism.Unity.UnityBootstrapper.Run(Boolean runWithDefaultConfiguration)
at Application_Client.Desktop.App.StartUp(Object sender, StartupEventArgs e) in D:\a\1\s\Application_Client.Desktop\App.xaml.cs:line 46
at System.Windows.Application.OnStartup(StartupEventArgs e)
at System.Windows.Application.<.ctor>b__1_0(Object unused)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at Application_Client.Desktop.App.Main()
Edit: callstack
Hereby the callstack of my problem:
> mscorlib.dll!System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(System.Reflection.AssemblyName assemblyRef, System.Security.Policy.Evidence assemblySecurity, System.Reflection.RuntimeAssembly reqAssembly, ref System.Threading.StackCrawlMark stackMark, System.IntPtr pPrivHostBinder, bool throwOnFileNotFound, bool forIntrospection, bool suppressSecurityChecks) Line 1859 C#
mscorlib.dll!System.Reflection.RuntimeAssembly.InternalLoad(string assemblyString, System.Security.Policy.Evidence assemblySecurity, ref System.Threading.StackCrawlMark stackMark, System.IntPtr pPrivHostBinder, bool forIntrospection) Line 1743 C#
mscorlib.dll!System.Reflection.RuntimeAssembly.InternalLoad(string assemblyString, System.Security.Policy.Evidence assemblySecurity, ref System.Threading.StackCrawlMark stackMark, bool forIntrospection) Line 1722 C#
mscorlib.dll!System.Reflection.Assembly.ReflectionOnlyLoad(string assemblyString) Line 328 C#
Prism.Wpf.dll!Prism.Modularity.DirectoryModuleCatalog.InnerModuleInfoLoader.OnReflectionOnlyResolve(System.ResolveEventArgs args, System.IO.DirectoryInfo directory) Unknown
mscorlib.dll!System.AppDomain.OnReflectionOnlyAssemblyResolveEvent(System.Reflection.RuntimeAssembly assembly, string assemblyFullName) Line 3191 C#
[Native to Managed Transition]
[Managed to Native Transition]
mscorlib.dll!System.Reflection.RuntimeAssembly.GetExportedTypes() Line 1517 C#
Prism.Wpf.dll!Prism.Modularity.DirectoryModuleCatalog.InnerModuleInfoLoader.GetNotAllreadyLoadedModuleInfos.AnonymousMethod__2(System.IO.FileInfo file) Unknown
System.Core.dll!System.Linq.Enumerable.SelectManyIterator<System.IO.FileInfo, Prism.Modularity.ModuleInfo>(System.Collections.Generic.IEnumerable<System.IO.FileInfo> source, System.Func<System.IO.FileInfo, System.Collections.Generic.IEnumerable<Prism.Modularity.ModuleInfo>> selector) Unknown
System.Core.dll!System.Linq.Buffer<Prism.Modularity.ModuleInfo>.Buffer(System.Collections.Generic.IEnumerable<Prism.Modularity.ModuleInfo> source) Unknown
System.Core.dll!System.Linq.Enumerable.ToArray<Prism.Modularity.ModuleInfo>(System.Collections.Generic.IEnumerable<Prism.Modularity.ModuleInfo> source) Unknown
Prism.Wpf.dll!Prism.Modularity.DirectoryModuleCatalog.InnerModuleInfoLoader.GetModuleInfos(string path) Unknown
[AppDomain (Application.Desktop.exe, #1) -> AppDomain (DiscoveryRegion, #2)]
Prism.Wpf.dll!Prism.Modularity.DirectoryModuleCatalog.InnerLoad() Unknown
Prism.Wpf.dll!Prism.Modularity.ModuleCatalog.Initialize() Unknown
Prism.Wpf.dll!Prism.Modularity.ModuleManager.Run() Unknown
Application.Desktop.exe!Application.Client.Desktop.Bootstrapper.InitializeModules() Line 73 C#
Prism.Unity.Wpf.dll!Prism.Unity.UnityBootstrapper.Run(bool runWithDefaultConfiguration) Unknown
Application.Desktop.exe!Application.Client.Desktop.App.StartUp(object sender, System.Windows.StartupEventArgs e) Line 46 C#
PresentationFramework.dll!System.Windows.Application.OnStartup(System.Windows.StartupEventArgs e) Unknown
PresentationFramework.dll!System.Windows.Application..ctor.AnonymousMethod__1_0(object unused) Unknown
WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate callback, object args, int numArgs) Unknown
WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.TryCatchWhen(object source, System.Delegate callback, object args, int numArgs, System.Delegate catchHandler) Unknown
WindowsBase.dll!System.Windows.Threading.DispatcherOperation.InvokeImpl() Unknown
WindowsBase.dll!MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(object obj) Unknown
mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Line 980 C#
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Line 928 C#
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) Line 917 C#
WindowsBase.dll!MS.Internal.CulturePreservingExecutionContext.Run(MS.Internal.CulturePreservingExecutionContext executionContext, System.Threading.ContextCallback callback, object state) Unknown
WindowsBase.dll!System.Windows.Threading.DispatcherOperation.Invoke() Unknown
WindowsBase.dll!System.Windows.Threading.Dispatcher.ProcessQueue() Unknown
WindowsBase.dll!System.Windows.Threading.Dispatcher.WndProcHook(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled) Unknown
WindowsBase.dll!MS.Win32.HwndWrapper.WndProc(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled) Unknown
WindowsBase.dll!MS.Win32.HwndSubclass.DispatcherCallbackOperation(object o) Unknown
WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate callback, object args, int numArgs) Unknown
WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.TryCatchWhen(object source, System.Delegate callback, object args, int numArgs, System.Delegate catchHandler) Unknown
WindowsBase.dll!System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority priority, System.TimeSpan timeout, System.Delegate method, object args, int numArgs) Unknown
WindowsBase.dll!MS.Win32.HwndSubclass.SubclassWndProc(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam) Unknown
[Native to Managed Transition]
[Managed to Native Transition]
WindowsBase.dll!System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame frame) Unknown
PresentationFramework.dll!System.Windows.Application.RunDispatcher(object ignore) Unknown
PresentationFramework.dll!System.Windows.Application.RunInternal(System.Windows.Window window) Unknown
Application.Desktop.exe!Application.Client.Desktop.App.Main() Unknown
Thanks in advance
It sounds like you are working with plugin architecture and are experiencing a bit of dll hell.
Without knowing the depths of the app or what runtime you're working (I assume it's .NET Framework), it's difficult to say exactly where the problem is but the crux of it is this: The runtime is looking for a dependency and it's not finding it.
Take a look at the AssemblyResolve event. Essentially, when the framework is asking for a dependency, this handler fires. Returning null is a "not found" and then the framework will look for the dependency in the "usual places". Places like
the same directory as executing assembly
the plugins folder
the Global Assembly Cache (GAC)
The main challenge with plugins (in my experience) is including dependencies and getting those dependencies loaded by the host. Take a look at how the locations of these modules of yours are identified and how/whether dependencies are included.
Changes to your filesystem or environment can produce these kinds of problems. Maybe your app was working and a Git Clean took out the DLL in the program directory. Maybe the dll is loaded into the GAC but the app is now expecting a different version.
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
}
private Assembly? CurrentDomain_AssemblyResolve(object? sender, ResolveEventArgs args)
{
var filePath = GetPathFromName(args.Name);
if(System.IO.File.Exists(filePath))
return Assembly.Load(filePath);
else
return null;
}
private string GetPathFromName(string name) => "my logic here";
}
I have some Telerik reports that are stored in database. To convert them into Reports I used such piece of code:
private Telerik.Reporting.Report GetReportFromXml(string xmlString)
{
using (StringReader xmlReader = new StringReader(xmlString))
{
Telerik.Reporting.XmlSerialization.ReportXmlSerializer xmlSerializer = new ReportXmlSerializer();
object res = xmlSerializer.Deserialize(xmlReader);
return res as Telerik.Reporting.Report;
}
}
Also I have two databases with absolutely same xmlString data.
The Problem:
With first database all works fine.
With second I get error on xmlSerializer.Deserialize(xmlReader):
CurrentDomain_UnhandledException
System.IO.FileLoadException: Could not load file or assembly 'Telerik.Reporting.Design, Version=10.1.16.504, Culture=neutral, PublicKeyToken=a9d7983dfcc261be' or one of its dependencies. An argument was out of its legal range. (Exception from HRESULT: 0x80131502)
File name: 'Telerik.Reporting.Design, Version=10.1.16.504, Culture=neutral, PublicKeyToken=a9d7983dfcc261be' ---> System.ArgumentOutOfRangeException: StartIndex cannot be less than zero.
Parameter name: startIndex
at System.String.Substring(Int32 startIndex, Int32 length)
at ?A0x6aa5279c.domain_AssemblyResolve(Object __unnamed000, ResolveEventArgs args)
at System.AppDomain.OnAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName)
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type)
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName)
at System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)
at System.Type.GetType(String typeName)
at System.ComponentModel.PropertyDescriptor.GetTypeFromName(String typeName)
at System.ComponentModel.PropertyDescriptor.get_Converter()
at Telerik.Reporting.Xml.ObjectXmlReaderWriterBase.GetTypeConverter(PropertyDescriptor prop)
at Telerik.Reporting.Xml.ObjectXmlReader.ReadValue(Object obj, PropertyDescriptor prop)
at Telerik.Reporting.Xml.ObjectXmlReader.ReadAttributes(Object obj, PropertyDescriptorCollection props)
at Telerik.Reporting.Xml.ObjectXmlReader.ReadProperties(Object obj)
at Telerik.Reporting.Xml.ObjectXmlReader.ReadObject(Type type)
at Telerik.Reporting.Xml.ObjectXmlReader.ReadXmlElement(String name)
at Telerik.Reporting.Xml.ObjectXmlReader.ReadCollection(Object collection)
at Telerik.Reporting.Xml.ObjectXmlReader.ReadProperties(Object obj)
at Telerik.Reporting.Xml.ObjectXmlReader.ReadObject(Type type)
at Telerik.Reporting.Xml.ObjectXmlReader.ReadXmlElement(String name)
at Telerik.Reporting.Xml.ObjectXmlReader.Deserialize(IResourceHandler handler)
at Telerik.Reporting.Xml.XmlSerializer.Deserialize(TextReader reader, IResourceHandler resourceHandler)
at Telerik.Reporting.XmlSerialization.ReportXmlSerializer.Deserialize(TextReader reader)
I want to mention that I use the same source code and I'm totally sure that parameter xmlString is equal in both situation.
I just changing connection and error appears.
I presume it's some database setting that force assembly to load. But project is huge and don't have a clue as to how to fix this and what I should pay attention to.
Telerik Reporting assemblies are strong-name signed and the error that you are reporting looks like a version incompatibility between current assemblies. In order to rule this out, update all your references (if using NuGet install/uninstall) and ensure that all of the Telerik Reporting dependencies have the same version. I assume that the different behavior between the two data connections is a side effect, rather than the original reason behind the problem.
i've installed glimpse through console package manager by this
Install-Package Glimpse.EF6
Glimpse.EF6/1.6.5 is installed on system and added in preferences.
following 'http://getglimpse.com/Docs/' tutorial, when i try to access http://mylocalhost/Glimpse.axd it shows me error
"HTTP Error 404.0 - Not Found
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable."
searched for the solution and found something here.
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
this line is already there app-start. tried to add keys in web.config but that shows error
"Server Error in '/' Application.
Runtime Error
Description: An exception occurred while processing your request. Additionally, another exception occurred while executing the custom error page for the first exception. The request has been terminated. "
using IIS express. any help will be appreciated.
EDIT: i turned off the custom errors and found this is the actual problem when i try to add those lines in web.config.
"Server Error in '/' Application.
Could not load type 'Glimpse.Core.Module' from assembly 'Glimpse.Core'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.TypeLoadException: Could not load type 'Glimpse.Core.Module' from assembly 'Glimpse.Core'.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[TypeLoadException: Could not load type 'Glimpse.Core.Module' from assembly 'Glimpse.Core'.]
System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type) +0
System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName) +70
System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark) +39
System.Type.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) +37
System.Web.Compilation.BuildManager.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) +65
System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, XmlNode node, Boolean checkAptcaBit, Boolean ignoreCase) +38
[ConfigurationErrorsException: Could not load type 'Glimpse.Core.Module' from assembly 'Glimpse.Core'.]
System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, XmlNode node, Boolean checkAptcaBit, Boolean ignoreCase) +348
System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, Boolean checkAptcaBit) +19
System.Web.Configuration.Common.ModulesEntry.SecureGetType(String typeName, String propertyName, ConfigurationElement configElement) +39
System.Web.Configuration.Common.ModulesEntry..ctor(String name, String typeName, String propertyName, ConfigurationElement configElement) +42
System.Web.HttpApplication.BuildIntegratedModuleCollection(List`1 moduleList) +158
System.Web.HttpApplication.GetModuleCollection(IntPtr appContext) +950
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +82
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +336
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296
[HttpException (0x80004005): Could not load type 'Glimpse.Core.Module' from assembly 'Glimpse.Core'.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9955652
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254"
alright the glimpse.EF6 was not working so i un-installed it and installed glipmse.mvc5 and it worked like a charm.
I am trying to change a running application from Pluralsight to write tables to SQL Server.
when i change the connection string from LocalDB to use SQL Server (see new app config sectionbelow), i get a System.InvalidOperationException was unhandled
HResult=-2146233079
Message=Failed to set Database.DefaultConnectionFactory to an instance of the 'System.Data.Entity.Infrastructure.SQLConnectionFactory, EntityFramework' type as specified in the application configuration. See inner exception for details.
Source=EntityFramework
The stack trace is below the app.config
new app config (gets exception):
app config sql server connection
<entityFramework>
<defaultConnectionFactory
type="System.Data.Entity.Infrastructure.SQLConnectionFactory, EntityFramework">
<parameters>
<parameter value="Data Source=GARY-PC\GARY;Initial Catalog=Dev;Integrated Security=True" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
old app config
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
Stack trace:
at System.Data.Entity.Internal.AppConfig.<.ctor>b__1()
at System.Lazy1.CreateValue()
at System.Lazy1.LazyInitValue()
at System.Lazy1.get_Value()
at System.Data.Entity.Internal.AppConfig.get_DefaultConnectionFactory()
at System.Data.Entity.Internal.LazyInternalConnection.Initialize()
at System.Data.Entity.Internal.LazyInternalConnection.get_ProviderName()
at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
at System.Data.Entity.Internal.InternalContext.Initialize()
at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)
at System.Data.Entity.Internal.Linq.InternalSet1.Initialize()
at System.Data.Entity.Internal.Linq.InternalSet1.GetEnumerator()
at System.Data.Entity.Infrastructure.DbQuery1.System.Collections.Generic.IEnumerable.GetEnumerator()
at System.Collections.Generic.List1..ctor(IEnumerable1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at ConsoleApp.Program.GetCustomers() in c:\Users\gary\Downloads\entity-framework5-getting-started\materials\4-ef5-m4-codefirst-exercise-files\SalesCodeFirst AFTER\ConsoleApp\Program.cs:line 22
at ConsoleApp.Program.Main(String[] args) in c:\Users\gary\Downloads\entity-framework5-getting-started\materials\4-ef5-m4-codefirst-exercise-files\SalesCodeFirst AFTER\ConsoleApp\Program.cs:line 15
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: System.TypeLoadException
HResult=-2146233054
Message=Could not load type 'System.Data.Entity.Infrastructure.SQLConnectionFactory' from assembly 'EntityFramework'.
Source=mscorlib
TypeName=System.Data.Entity.Infrastructure.SQLConnectionFactory
StackTrace:
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type)
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName)
at System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)
at System.Type.GetType(String typeName, Boolean throwOnError)
at System.Data.Entity.Internal.ConfigFile.DefaultConnectionFactoryElement.GetFactoryType()
at System.Data.Entity.Internal.AppConfig.<.ctor>b__1()
InnerException:
I get the error at the end when I try to start a project I'm working on from Visual Studio. It worked fine until a few hours ago. After some minor unrelated changes it stopped working when starting from Visual Studio. It works fine when run from explorer. Even old version vom revision control (where this part of the code is exactly the same and has worked without any problems) behave the same way so it doesn't seem to be a problem in my code.
The code at Program.cs:line 14 is the following:
private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
Any ideas on how to solve this?
System.TypeInitializationException was unhandled
Message=The type initializer for ...' threw an exception.
Source=...
TypeName=...
StackTrace:
at ....Main(String[] args)
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: System.Runtime.InteropServices.SEHException
Message=External component has thrown an exception.
Source=mscorlib
ErrorCode=-2147467259
StackTrace:
at System.Security.Policy.PEFileEvidenceFactory.GetLocationEvidence(SafePEFileHandle peFile, SecurityZone& zone, StringHandleOnStack retUrl)
at System.Security.Policy.PEFileEvidenceFactory.GenerateLocationEvidence()
at System.Security.Policy.PEFileEvidenceFactory.GenerateEvidence(Type evidenceType)
at System.Security.Policy.AssemblyEvidenceFactory.GenerateEvidence(Type evidenceType)
at System.Security.Policy.Evidence.GenerateHostEvidence(Type type, Boolean hostCanGenerate)
at System.Security.Policy.Evidence.GetHostEvidenceNoLock(Type type)
at System.Security.Policy.Evidence.GetHostEvidence(Type type, Boolean markDelayEvaluatedEvidenceUsed)
at System.Security.Policy.AppDomainEvidenceFactory.GenerateEvidence(Type evidenceType)
at System.Security.Policy.Evidence.GenerateHostEvidence(Type type, Boolean hostCanGenerate)
at System.Security.Policy.Evidence.GetHostEvidenceNoLock(Type type)
at System.Security.Policy.Evidence.RawEvidenceEnumerator.MoveNext()
at System.Security.Policy.Evidence.EvidenceEnumerator.MoveNext()
at System.Configuration.ClientConfigPaths.GetEvidenceInfo(AppDomain appDomain, String exePath, String& typeName)
at System.Configuration.ClientConfigPaths.GetTypeAndHashSuffix(AppDomain appDomain, String exePath)
at System.Configuration.ClientConfigPaths..ctor(String exePath, Boolean includeUserConfig)
at System.Configuration.ClientConfigPaths.GetPaths(String exePath, Boolean includeUserConfig)
at System.Configuration.ClientConfigurationHost.RequireCompleteInit(IInternalConfigRecord record)
at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String sectionName)
at System.Configuration.ConfigurationManager.GetSection(String sectionName)
at NLog.Config.XmlLoggingConfiguration.get_AppConfig()
at NLog.LogFactory.get_Configuration()
at NLog.LogFactory.GetLogger(LoggerCacheKey cacheKey)
at NLog.LogFactory.GetLogger(String name)
at NLog.LogManager.GetCurrentClassLogger()
at ....Program..cctor() in C:\...\Program.cs:line 14
InnerException:
Check the following post on the Avira support site for details of the problem and a work around. The issue is related to the last product update:
http://www.avira.com/en/support-for-business-knowledgebase-detail/kbid/805