How to understand root cause of System.IO.FileNotFoundException? - c#

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";
}

Related

C# program does not work in the deployed client. Mysql Connector error

I have created an application in visual studio that uses Mysql Connector to access a database of a server. When starting the program in the developing PC it works fine. When i install this program in another PC after some seconds after running there pop ups a error such :
Problem Event Name: CLR20r3
Problem Signature 01: ServiceHoster.exe
Problem Signature 02: 1.0.0.0
Problem Signature 03: 59516cb4
Problem Signature 04: MySql.Data
Problem Signature 05: 6.9.9.0
Problem Signature 06: 5764222b
Problem Signature 07: 712
Problem Signature 08: 59
Problem Signature 09: MySql.Data.MySqlClient.MySql
OS Version: 6.1.7601.2.1.0.272.7
Locale ID: 1031
Additional Information 1: 0a9e
Additional Information 2: 0a9e372d3b4ad19135b953a78882e789
Additional Information 3: 0a9e
Additional Information 4: 0a9e372d3b4ad19135b953a78882e789
When i Debug, on the client machine using visual studio i get the following exception:
MySql.Data.MySqlClient.MySqlException occurred
HResult=0x80004005
Message=Unable to connect to any of the specified MySQL hosts.
Source=<Cannot evaluate the exception source>
StackTrace:
at MySql.Data.MySqlClient.NativeDriver.Open()
at MySql.Data.MySqlClient.Driver.Open()
at MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings)
at MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection()
at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()
at MySql.Data.MySqlClient.MySqlPool.TryToGetDriver()
at MySql.Data.MySqlClient.MySqlPool.GetConnection()
at MySql.Data.MySqlClient.MySqlConnection.Open()
at DataExchangeLayer.DataExchange.SyncTrainersFromBackendToFrontend()
at ServiceHoster.ViewModel.MainViewModel.UpdateBackendWithFrontend()
at ServiceHoster.ViewModel.MainViewModel.Timer_Tick(Object sender, EventArgs e)
at System.Windows.Threading.DispatcherTimer.FireTick(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 System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(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 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.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at System.Windows.Application.Run()
at ServiceHoster.App.Main()
Connection string is as following:
Server=server;Port=some_port;database=database_name;Uid=username;Pwd=password;persistsecurityinfo=True

WPF COMException Crashes Application At Startup (Started Today)

I have just today started seeing this Exception out in the wild on application launch with an app that has been in production for 3 years.
System.TypeInitializationException: The type initializer for 'MS.Win32.Penimc.UnsafeNativeMethods' threw an exception. ---> System.Runtime.InteropServices.COMException: Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
at MS.Win32.Penimc.UnsafeNativeMethods.CoCreateInstance(Guid& clsid, Object punkOuter, Int32 context, Guid& iid)
at MS.Win32.Penimc.UnsafeNativeMethods.CreatePimcManager()
at MS.Win32.Penimc.UnsafeNativeMethods..cctor()
--- End of inner exception stack trace ---
at MS.Win32.Penimc.UnsafeNativeMethods.CreateResetEvent(IntPtr& handle)
at System.Windows.Input.PenThreadWorker..ctor()
at System.Windows.Input.PenThreadPool.GetPenThreadForPenContextHelper(PenContext penContext)
at System.Windows.Input.PenThreadPool.GetPenThreadForPenContext(PenContext penContext)
at System.Windows.Input.StylusWisp.WispTabletDeviceCollection.UpdateTabletsImpl()
at System.Windows.Input.StylusWisp.WispTabletDeviceCollection.UpdateTablets()
at System.Windows.Input.StylusWisp.WispTabletDeviceCollection..ctor()
at System.Windows.Input.StylusWisp.WispLogic.get_WispTabletDevices()
at System.Windows.Input.StylusWisp.WispLogic.RegisterHwndForInput(InputManager inputManager, PresentationSource inputSource)
at System.Windows.Interop.HwndStylusInputProvider..ctor(HwndSource source)
at System.Windows.Interop.HwndSource.Initialize(HwndSourceParameters parameters)
at System.Windows.Window.CreateSourceWindow(Boolean duringShow)
at System.Windows.Window.CreateSourceWindowDuringShow()
at System.Windows.Window.SafeCreateWindowDuringShow()
at System.Windows.Window.ShowHelper(Object booleanBox)
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 System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(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 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.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at APSSSentinel.App.Main()
Apparently, some developers using VS2017 who got a Windows update that installed .NET 4.7 have been getting this crash as well, it appears the recommended workaround for now is to turn touch support off.
https://developercommunity.visualstudio.com/content/problem/55303/visual-studio-may-terminate-unexpectedly-when-runn.html
With my application, this is not ideal. Has anyone else run into this, and found any other sort of workaround?
Update: Microsoft has now fixed this problem in a manual update (as noted by Jürgen), personally I will stick with the workaround until the fix is in the automatic update because it would be a lot of work to make every user install a manual update.
This is obviously a bug in .Net 4.7 that affects Windows 7 and 8/8.1 systems that have a touch input device. Therefore one can hope that Microsoft addresses this in a future update. Meanwhile the only way to retain full functionality is by uninstalling and hiding the update.
Other option is disabling the stylys and touch support either in app.config (like in your link) or in the code if the app is compiled with 4.6 or newer. You didn't specify why that is not ideal but I assume those features are needed? Notice that the disabling doesn't mean that every app is unusable with touch devices, but rather that they only use features that are accessible with a mouse. Update: Apparently touch device users without a mouse will have trouble using UI that requires scrolling.
Here's the code examples for those who come here seeking quick fix:
In App.config (works with apps compiled with any framework version)
<configuration>
<runtime>
<AppContextSwitchOverrides value="Switch.System.Windows.Input.Stylus.DisableStylusAndTouchSupport=true" />
</runtime>
</configuration>
In code (when compiled with .Net Framework >= 4.6)
protected override void OnStartup(StartupEventArgs e)
{
AppContext.SetSwitch("Switch.System.Windows.Input.Stylus.DisableStylusAndTouchSupport", true);
base.OnStartup(e);
}
Microsoft has fixed the issue with .NET 4.7 meanwhile, see
https://support.microsoft.com/en-US/help/4033488/comexception-error-from-wpf-applications-after-the-net-framework-4-7-i

Locating the source of an UnhandledException

My program seems to have a bug in it which I'm finding hard to track down. The program is multithreaded and quite complex. In a nutshell it communicates with multiple clients using asynchronous sockets and writes to the database.
A System.Reflection.TargetInvocationException is thrown when I hammer the program with client communications and hold down the enter key to spam writes into the database. At some point in time the exception is thrown which I'm catching with the following snippet of code in the constructor of the main window:
VMMainWindow()
{
...
System.Windows.Threading.Dispatcher.CurrentDispatcher.UnhandledException += new System.Windows.Threading.DispatcherUnhandledExceptionEventHandler(CurrentDispatcher_UnhandledException);
....
}
static void CurrentDispatcher_UnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
{
string str = e.ToString();
}
I don't have much to work with but I was wondering if someone could suggest some tools or or point me in the right direction to help me detect the location of this exception. The exception in detail is pasted below.
System.Reflection.TargetInvocationException was unhandled Message=Exception has been thrown by the target of an invocation. Source=mscorlib StackTrace:
at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Delegate.DynamicInvokeImpl(Object[] args)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, 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.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 MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.InvokeImpl(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.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.Run()
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at System.Windows.Application.Run()
at SupernovaServer.App.Main() in D:\Projects\Supernova Server\Server\obj\x86\Debug\App.g.cs:line 0
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.ArgumentOutOfRangeException
Message=Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
Source=mscorlib
ParamName=index
StackTrace:
at System.ThrowHelper.ThrowArgumentOutOfRangeException()
at System.Collections.Generic.List`1.get_Item(Int32 index)
at System.Collections.ObjectModel.Collection`1.System.Collections.IList.get_Item(Int32 index)
at System.Windows.Data.ListCollectionView.AdjustBefore(NotifyCollectionChangedAction action, Object item, Int32 index)
at System.Windows.Data.ListCollectionView.ProcessCollectionChanged(NotifyCollectionChangedEventArgs args)
at System.Windows.Data.CollectionView.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
InnerException:
Is it possible that you have multiple threads making concurrent accesses to a collection that isn't thread-safe? Say, one thread removing an item while another is reading or adding? That would definitely cause this type of error. In general, the .NET collection classes (except for those in System.Collections.Concurrent) are not thread-safe. You can have multiple readers, but any modification of the collection is going to require exclusive access--protected by a lock or a reader/writer lock.
It's pretty safe to assume App.g.cs is not where the problem lies, so as you said, there isn't much to go on. So here's my hint to you: look at the inner exception. Those things are quite handy, and I'll be willing to bet you have an inner exception at least one layer deep.

WPF DataGrid Selected Items NullArgumentException

I have started getting the above exception from a command linked from a DelegateCommand to a ViewModel. The exception says
{"Value cannot be null.\r\nParameter name: key"}
StackTrace...
at System.Collections.Generic.Dictionary`2.FindEntry(TKey key)
at System.Collections.Generic.Dictionary`2.TryGetValue(TKey key, TValue& value)
at System.Windows.Controls.DataGridItemAttachedStorage.TryGetValue(Object item, DependencyProperty property, Object& value)
at System.Windows.Controls.DataGridRow.RestoreAttachedItemValue(DependencyObject objectWithProperty, DependencyProperty property)
at System.Windows.Controls.DataGridRow.SyncProperties(Boolean forcePrepareCells)
at System.Windows.Controls.DataGridRow.PrepareRow(Object item, DataGrid owningDataGrid)
at System.Windows.Controls.DataGrid.PrepareContainerForItemOverride(DependencyObject element, Object item)
at System.Windows.Controls.ItemsControl.MS.Internal.Controls.IGeneratorHost.PrepareItemContainer(DependencyObject container, Object item)
at System.Windows.Controls.ItemContainerGenerator.System.Windows.Controls.Primitives.IItemContainerGenerator.PrepareItemContainer(DependencyObject container)
at System.Windows.Controls.VirtualizingStackPanel.InsertContainer(Int32 childIndex, UIElement container, Boolean isRecycled)
at System.Windows.Controls.VirtualizingStackPanel.AddContainerFromGenerator(Int32 childIndex, UIElement child, Boolean newlyRealized)
at System.Windows.Controls.VirtualizingStackPanel.MeasureOverride(Size constraint)
at System.Windows.Controls.Primitives.DataGridRowsPresenter.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.ContextLayoutManager.UpdateLayout()
at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
at System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork()
at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, 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.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 MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.InvokeImpl(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.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.Run()
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at System.Windows.Application.Run()
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()
The funny thing is I have a command 'wired' from the View to the ViewModel in just the same way and it works fine.
I'd include the offending code, but the intellisense breaks out at 'No Source Available'. Where is this coming from and how can I get rid of it?!
EDIT:
XAML:
<Grid Grid.Column="0" Grid.Row="0">
<DataGrid ItemsSource="{Binding Path=ObservableCollectionOfActiveObjects}" SelectedItem="{Binding Path=SelectedObject}" IsEnabled="{Binding Path=IsDoingNothing}">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Id}" Header="ID"/>
<DataGridTextColumn Binding="{Binding Name}" Header="Object Name"/>
</DataGrid.Columns>
</DataGrid>
</Grid>
ViewModel
private void DoDataGridCommand()
{
if (DoHaveAllTheCollections() &&
selectedObject != null &&
!otherListOfObject.Contains(selectedObject))
{
activeObjects.Remove(selectedObject);
excludedObjects.Add(selectedObject);
RaisePropertyChanged(activeObjectsPropertyName);
RaisePropertyChanged(excludedObjectsPropertyName);
}
}
I hope this helps.... the exception throws just after the DoDataGridCommand() ends...
EDIT2:
I believe I have found the answer.
While playing with the two lists of objects (happened to be ObservableCollections, maybe this makes a difference?), in the example of the 'switch operation' that worked I was adding the object to the new list and then removing it from the old one.
In the one that threw the exception, I was adding it to the collection and then removing it from the other. I guess this is because (and please input would be appreciated if my assumption is wrong), as everything is a reference in C#, I moved the 'pointer' then removed the pointers reference to the old list, when, I guess it didn't exist anymore. I suppose it's a rookie mistake, but I hardly think I deserve demerits! Ah well, at least the problem appears solved! Many thanks for your inputs.
Could you check the data that is being bound to the grid? It looks a bit like the DataGrid is looking for a column/property in the rows that doesn't exist.

Only while running on VS 2010: COMException: Catastrophic Failure: Error Code: -2147418113

I am stuck with this error: while trying to use an old DLL in .Net Framework 4.0
If I change project target type to 3.5 then no error appears.
The strange is that all this happen Only while running inside VS 2010. If I run the executable from Windows Explorer, no problem occurs in 3.5 and 4.0.
Seems like some bug in vshost? VS 2010 Express, or .net framework?
UPDATE: This BUG only happen on WPF Standalone Application, if a change it to XBAP WPF I can use the dll without bigger problems, only a message telling it could no stop debugging.
I will leave this question open here, waiting to see if there is some progress on the connect.microsoft.com about this ticket.
Is there some way to make my .net4 app.config load this specific dll(CobreBemX.dll) using the .net 3.5 ?
I think this is some bug then i submitted it to https://connect.microsoft.com/VisualStudio/feedback/details/636697/comexception-was-unhandled-catastrophic-failure
Here is the code where it throws that COMException:
//Cria instância do objeto CobreBemX
CobreBemX.ContaCorrente _CobreBemX = new CobreBemX.ContaCorrenteClass();
//Monta arquivo de licença de teste para banco 001 carteira 18
_CobreBemX.ArquivoLicenca = #"C:\CobreBemX\Exemplos\Licencas\237-09.conf"; // THIS LINES CAUSES THE PROBLEM ON .NET 4.0 IF I CHANGE TARGET FRAMEWORK TO 3.5 NO PROBLEM HAPPENS
This is the stack trace:
System.Runtime.InteropServices.COMException was unhandled
Message=Falha catastrófica
Source=CobreBemX.ContaCorrente
ErrorCode=-2147418113
StackTrace:
at CobreBemX.ContaCorrenteClass.set_ArquivoLicenca(String Value)
at EmissorBoletosWindows.MainWindow.button1_Click(Object sender, RoutedEventArgs e) in C:\inetpub\wwwroot\CRM\Cobranca\EmissorBoletosWindows\EmissorBoletosWindows\MainWindow.xaml.cs:line 90
at EmissorBoletosWindows.MainWindow.Window_Loaded(Object sender, RoutedEventArgs e) in C:\inetpub\wwwroot\CRM\Cobranca\EmissorBoletosWindows\EmissorBoletosWindows\MainWindow.xaml.cs:line 39
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
at System.Windows.BroadcastEventHelper.BroadcastEvent(DependencyObject root, RoutedEvent routedEvent)
at System.Windows.BroadcastEventHelper.BroadcastLoadedEvent(Object root)
at MS.Internal.LoadedOrUnloadedOperation.DoWork()
at System.Windows.Media.MediaContext.FireLoadedPendingCallbacks()
at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
at System.Windows.Media.MediaContext.Resize(ICompositionTarget resizedCompositionTarget)
at System.Windows.Interop.HwndTarget.OnResize()
at System.Windows.Interop.HwndTarget.HandleMessage(WindowMessage msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Interop.HwndSource.HwndTargetFilterMessage(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 MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.InvokeImpl(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.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
at System.Windows.Window.ShowHelper(Object booleanBox)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, 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.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 MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.InvokeImpl(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.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.Run()
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at System.Windows.Application.Run()
at EmissorBoletosWindows.App.Main() in C:\inetpub\wwwroot\CRM\Cobranca\EmissorBoletosWindows\EmissorBoletosWindows\obj\x86\Debug\App.g.cs:line 0
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:
If you examine the top of the stack, the method suggests the library is performing some software licensing processing. My guess (and it is a guess) is that the library is using the executable's name and path to locate the license and, because the application is running through VSHost, this is failing causing an error which is expressed as a COM exception.
The fact it works fine outside of VSHost would lend weight to this. You could use a tool such as FileMon to possibly see where it is tripping up.
For now this has no solution other than use XBAP

Categories

Resources