Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception when loading the system tray icon #525

Open
KIRIZAMERAN opened this issue Oct 3, 2019 · 10 comments
Open

Exception when loading the system tray icon #525

KIRIZAMERAN opened this issue Oct 3, 2019 · 10 comments
Labels
🔷 Bug 🐛 Type • An undesired situation happens. ⬜ Help Wanted 💪 Status • Help is wanted for this issue.

Comments

@KIRIZAMERAN
Copy link

KIRIZAMERAN commented Oct 3, 2019

Net.Framework: 4.8.0
System: Windows 10 1903
Language: Simplified Chinese

Stack trace:

Set property 'ScreenToGif.Controls.NotifyIcon.IconSource' threw an exception.

at System.Windows.Markup.XamlReader.RewrapException(Exception e, IXamlLineInfo lineInfo, Uri baseUri)
   at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
   at System.Windows.ResourceDictionary.CreateObject(KeyRecord key)
   at System.Windows.ResourceDictionary.OnGettingValue(Object key, Object& value, Boolean& canCache)
   at System.Windows.ResourceDictionary.OnGettingValuePrivate(Object key, Object& value, Boolean& canCache)
   at System.Windows.ResourceDictionary.GetValueWithoutLock(Object key, Boolean& canCache)
   at System.Windows.ResourceDictionary.GetValue(Object key, Boolean& canCache)
   at System.Windows.Application.FindResource(Object resourceKey)
   at ScreenToGif.App.Application_Startup(Object sender, StartupEventArgs e)
   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)
@NickeManarin NickeManarin added 🔷 Bug 🐛 Type • An undesired situation happens. ⬜ Help Wanted 💪 Status • Help is wanted for this issue. labels Oct 3, 2019
@mrfearless
Copy link

same as #388

@NickeManarin
Copy link
Owner

Strange, the only place where I change the icon is right at the beginning of the app:

Like this: IconSource="/Resources/Logo.ico"

Are you running your Windows at a different color space than 32bits?
I'm going to add some checks to avoid the crash, at least.

@NickeManarin
Copy link
Owner

NickeManarin commented Oct 3, 2019

Can you test if it opens? This version is just for testing if it opens or not, there's some other broken features, so ignore it.
If it's opening, check if the icon is appearing on your notification area.

cc @mrfearless and @KIRIZAMERAN

ScreenToGif_Test.zip

@mrfearless
Copy link

mrfearless commented Oct 3, 2019

It opens without any errors or messages displayed. Goes straight to the startup screen. The notification icon is blank - as in, it appears along side other icons (i noticed the shuffle as it added itself) in the tray notification area, but no icon is showing - just a fully transparent icon or space for where an icon would be.

Running Win7 x64 with full 32bit desktop colors

@NickeManarin
Copy link
Owner

Thank you. At least it opens now.

Now I need to understand why my icon is not loading.
It's strange because the file is attached to the executable and is the same that appears in the taskbar and in the executable file in the Windows Explorer. I'm assuming that you can see the ScreenToGif icon on your taskbar and in the executable file.

ScreenToGif_Test_2.zip
Here's another with a slightly changed initialization behavior.
If it still does not work, I'll have to export the icon again, exporting as 256 colors too.

@KIRIZAMERAN
Copy link
Author

KIRIZAMERAN commented Oct 3, 2019

test 1 open without error but icon problem same as mrfearless
test 2 open with error message:
the app crashed

System.Drawing.Initialize
at System.Drawing.Icon.Initialize(Int32 width, Int32 height)
at ScreenToGif.App.Application_Startup(Object sender, StartupEventArgs e)
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)

Running Win10 x64 with full 32bit desktop colors

@NickeManarin
Copy link
Owner

Thank you. Same crash, looks like it's the same reason.
It's hard to know exactly what's wrong, specially without having a computer having the same crash.
I added the icon with 256 colors too.

ScreenToGif_Test_3.zip

@mrfearless
Copy link

Test 2 crashed, Test 3 works, but icon is blank in tray - same as Test 1

@NickeManarin NickeManarin changed the title Can't run it on win10 1903 Exception when loading the system tray icon Nov 18, 2019
@NickeManarin
Copy link
Owner

Stack trace from @mrfearless

► Title - 
	On Dispacher Unhandled Exception - Unknown
▬ Message - 
	Set property 'ScreenToGif.Controls.NotifyIcon.IconSource' threw an exception.
○ Type - 
	System.Windows.Markup.XamlParseException
♦ [Version] Date/Hour - 
	[2.13.3] 10/16/2018 10:55:46
▲ Source - 
	PresentationFramework
▼ TargetSite - 
	Void RewrapException(System.Exception, System.Xaml.IXamlLineInfo, System.Uri)
♠ StackTrace - 
   at System.Windows.Markup.XamlReader.RewrapException(Exception e, IXamlLineInfo lineInfo, Uri baseUri)
   at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
   at System.Windows.ResourceDictionary.CreateObject(KeyRecord key)
   at System.Windows.ResourceDictionary.OnGettingValue(Object key, Object& value, Boolean& canCache)
   at System.Windows.ResourceDictionary.OnGettingValuePrivate(Object key, Object& value, Boolean& canCache)
   at System.Windows.ResourceDictionary.GetValueWithoutLock(Object key, Boolean& canCache)
   at System.Windows.ResourceDictionary.GetValue(Object key, Boolean& canCache)
   at System.Windows.Application.FindResource(Object resourceKey)
   at ScreenToGif.App.Application_Startup(Object sender, StartupEventArgs e)
   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)

▬▬ Message - 
	The operation completed successfully
○○ Type - 
	System.ComponentModel.Win32Exception
▲▲ Source - 
	System.Drawing
▼▼ TargetSite - 
	Void Initialize(Int32, Int32)
♠♠ StackTrace - 
   at System.Drawing.Icon.Initialize(Int32 width, Int32 height)
   at ScreenToGif.ImageUtil.ImageMethods.ToIcon(ImageSource imageSource)
   at ScreenToGif.Controls.NotifyIcon.IconSourcePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
   at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
   at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
   at System.Windows.Baml2006.WpfMemberInvoker.SetValue(Object instance, Object value)
   at MS.Internal.Xaml.Runtime.ClrObjectRuntime.SetValue(Object inst, XamlMember property, Object value)

@NickeManarin
Copy link
Owner

NickeManarin commented Nov 18, 2019

From what I know about this error, it's Windows telling the user that it can't load anything else.
Too many GDI objects were already loaded.

If this issue happens again with you people, can you open Task Manager and go to Details, and right click on the header of the data grid, enable GDI objects and see if there's a process eating too much GDI objects.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔷 Bug 🐛 Type • An undesired situation happens. ⬜ Help Wanted 💪 Status • Help is wanted for this issue.
Projects
None yet
Development

No branches or pull requests

3 participants