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

System.Drawing.Icon is partly incompatible with Mono's implementation #17

Open
QianNangong opened this issue Feb 6, 2019 · 1 comment

Comments

@QianNangong
Copy link

The program is
https://ppmforums.com/download.php?id=29787
It works fine with some layout glitches when used with Mono's implementation, but it won't run with sysdrawing-coregraphics, it will throw such an exception.

Unhandled Exception:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: stream
  at System.Drawing.Icon.InitFromStreamWithSize (System.IO.Stream stream, System.Int32 width, System.Int32 height) [0x00039] in /Users/alpine/mac-playground/sysdrawing-coregraphics/System.Drawing/Icon.cs:250 
  at System.Drawing.Icon..ctor (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) [0x000a9] in /Users/alpine/mac-playground/sysdrawing-coregraphics/System.Drawing/Icon.cs:128 
  at (wrapper managed-to-native) System.Reflection.MonoCMethod.InternalInvoke(System.Reflection.MonoCMethod,object,object[],System.Exception&)
  at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters, System.Boolean wrapExceptions) [0x00005] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.2.1.13/src/Xamarin.Mac/mcs/class/corlib/System.Reflection/MonoMethod.cs:667 
   --- End of inner exception stack trace ---
  at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters, System.Boolean wrapExceptions) [0x00012] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.2.1.13/src/Xamarin.Mac/mcs/class/corlib/System.Reflection/MonoMethod.cs:673 
  at System.Reflection.MonoCMethod.DoInvoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0007a] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.2.1.13/src/Xamarin.Mac/mcs/class/corlib/System.Reflection/MonoMethod.cs:657 
  at System.Reflection.MonoCMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0002f] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.2.1.13/src/Xamarin.Mac/mcs/class/corlib/System.Reflection/MonoMethod.cs:638 
  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.2.1.13/src/Xamarin.Mac/mcs/class/referencesource/mscorlib/system/reflection/methodbase.cs:229 
  at System.Reflection.RuntimeConstructorInfo.SerializationInvoke (System.Object target, System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) [0x00000] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.2.1.13/src/Xamarin.Mac/mcs/class/corlib/System.Reflection/MonoMethod.cs:584 
  at System.Runtime.Serialization.ObjectManager.CompleteISerializableObject (System.Object obj, System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) [0x00059] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.2.1.13/src/Xamarin.Mac/mcs/class/referencesource/mscorlib/system/runtime/serialization/objectmanager.cs:874 
  at System.Runtime.Serialization.ObjectManager.FixupSpecialObject (System.Runtime.Serialization.ObjectHolder holder) [0x0007b] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.2.1.13/src/Xamarin.Mac/mcs/class/referencesource/mscorlib/system/runtime/serialization/objectmanager.cs:259 
  at System.Runtime.Serialization.ObjectManager.DoFixups () [0x0005a] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.2.1.13/src/Xamarin.Mac/mcs/class/referencesource/mscorlib/system/runtime/serialization/objectmanager.cs:925 
  at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize (System.Runtime.Remoting.Messaging.HeaderHandler handler, System.Runtime.Serialization.Formatters.Binary.__BinaryParser serParser, System.Boolean fCheck, System.Boolean isCrossAppDomain, System.Runtime.Remoting.Messaging.IMethodCallMessage methodCallMessage) [0x00077] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.2.1.13/src/Xamarin.Mac/mcs/class/referencesource/mscorlib/system/runtime/serialization/formatters/binary/binaryobjectreader.cs:181 
  at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize (System.IO.Stream serializationStream, System.Runtime.Remoting.Messaging.HeaderHandler handler, System.Boolean fCheck, System.Boolean isCrossAppDomain, System.Runtime.Remoting.Messaging.IMethodCallMessage methodCallMessage) [0x00099] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.2.1.13/src/Xamarin.Mac/mcs/class/referencesource/mscorlib/system/runtime/serialization/formatters/binary/binaryformatter.cs:197 
  at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize (System.IO.Stream serializationStream, System.Runtime.Remoting.Messaging.HeaderHandler handler, System.Boolean fCheck, System.Runtime.Remoting.Messaging.IMethodCallMessage methodCallMessage) [0x00000] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.2.1.13/src/Xamarin.Mac/mcs/class/referencesource/mscorlib/system/runtime/serialization/formatters/binary/binaryformatter.cs:173 
  at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize (System.IO.Stream serializationStream, System.Runtime.Remoting.Messaging.HeaderHandler handler, System.Boolean fCheck) [0x00000] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.2.1.13/src/Xamarin.Mac/mcs/class/referencesource/mscorlib/system/runtime/serialization/formatters/binary/binaryformatter.cs:118 
  at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize (System.IO.Stream serializationStream, System.Runtime.Remoting.Messaging.HeaderHandler handler) [0x00000] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.2.1.13/src/Xamarin.Mac/mcs/class/referencesource/mscorlib/system/runtime/serialization/formatters/binary/binaryformatter.cs:149 
  at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize (System.IO.Stream serializationStream) [0x00000] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.2.1.13/src/Xamarin.Mac/mcs/class/referencesource/mscorlib/system/runtime/serialization/formatters/binary/binaryformatter.cs:111 
  at System.Resources.ResourceReader.DeserializeObject (System.Int32 typeIndex) [0x00008] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.2.1.13/src/Xamarin.Mac/mcs/class/referencesource/mscorlib/system/resources/resourcereader.cs:838 
  at System.Resources.ResourceReader._LoadObjectV2 (System.Int32 pos, System.Resources.ResourceTypeCode& typeCode) [0x0035c] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.2.1.13/src/Xamarin.Mac/mcs/class/referencesource/mscorlib/system/resources/resourcereader.cs:808 
  at System.Resources.ResourceReader.LoadObjectV2 (System.Int32 pos, System.Resources.ResourceTypeCode& typeCode) [0x00000] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.2.1.13/src/Xamarin.Mac/mcs/class/referencesource/mscorlib/system/resources/resourcereader.cs:679 
  at System.Resources.ResourceReader.LoadObject (System.Int32 pos, System.Resources.ResourceTypeCode& typeCode) [0x00022] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.2.1.13/src/Xamarin.Mac/mcs/class/referencesource/mscorlib/system/resources/resourcereader.cs:588 
  at System.Resources.RuntimeResourceSet.GetObject (System.String key, System.Boolean ignoreCase, System.Boolean isString) [0x000be] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.2.1.13/src/Xamarin.Mac/mcs/class/referencesource/mscorlib/system/resources/runtimeresourceset.cs:331 
  at System.Resources.RuntimeResourceSet.GetObject (System.String key, System.Boolean ignoreCase) [0x00000] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.2.1.13/src/Xamarin.Mac/mcs/class/referencesource/mscorlib/system/resources/runtimeresourceset.cs:286 
  at System.Resources.ResourceManager.GetObject (System.String name, System.Globalization.CultureInfo culture, System.Boolean wrapUnmanagedMemStream) [0x00028] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.2.1.13/src/Xamarin.Mac/mcs/class/referencesource/mscorlib/system/resources/resourcemanager.cs:1404 
  at System.Resources.ResourceManager.GetObject (System.String name) [0x00000] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.2.1.13/src/Xamarin.Mac/mcs/class/referencesource/mscorlib/system/resources/resourcemanager.cs:1360 
  at FontEditor.MainForm.InitializeComponent () [0x0350e] in <ca161138f7504b689b385d55224d8623>:0 
  at FontEditor.MainForm..ctor (System.String FileName) [0x00006] in <ca161138f7504b689b385d55224d8623>:0 
  at (wrapper remoting-invoke-with-check) FontEditor.MainForm..ctor(string)
  at FontEditor.MainForm.Main (System.String[] args) [0x00018] in <ca161138f7504b689b385d55224d8623>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: stream
  at System.Drawing.Icon.InitFromStreamWithSize (System.IO.Stream stream, System.Int32 width, System.Int32 height) [0x00039] in /Users/alpine/mac-playground/sysdrawing-coregraphics/System.Drawing/Icon.cs:250 
  at System.Drawing.Icon..ctor (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) [0x000a9] in /Users/alpine/mac-playground/sysdrawing-coregraphics/System.Drawing/Icon.cs:128 
  at (wrapper managed-to-native) System.Reflection.MonoCMethod.InternalInvoke(System.Reflection.MonoCMethod,object,object[],System.Exception&)
  at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters, System.Boolean wrapExceptions) [0x00005] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.2.1.13/src/Xamarin.Mac/mcs/class/corlib/System.Reflection/MonoMethod.cs:667 
   --- End of inner exception stack trace ---
  at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters, System.Boolean wrapExceptions) [0x00012] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.2.1.13/src/Xamarin.Mac/mcs/class/corlib/System.Reflection/MonoMethod.cs:673 
  at System.Reflection.MonoCMethod.DoInvoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0007a] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.2.1.13/src/Xamarin.Mac/mcs/class/corlib/System.Reflection/MonoMethod.cs:657 
  at System.Reflection.MonoCMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0002f] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.2.1.13/src/Xamarin.Mac/mcs/class/corlib/System.Reflection/MonoMethod.cs:638 
  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.2.1.13/src/Xamarin.Mac/mcs/class/referencesource/mscorlib/system/reflection/methodbase.cs:229 
  at System.Reflection.RuntimeConstructorInfo.SerializationInvoke (System.Object target, System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) [0x00000] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.2.1.13/src/Xamarin.Mac/mcs/class/corlib/System.Reflection/MonoMethod.cs:584 
  at System.Runtime.Serialization.ObjectManager.CompleteISerializableObject (System.Object obj, System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) [0x00059] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.2.1.13/src/Xamarin.Mac/mcs/class/referencesource/mscorlib/system/runtime/serialization/objectmanager.cs:874 
  at System.Runtime.Serialization.ObjectManager.FixupSpecialObject (System.Runtime.Serialization.ObjectHolder holder) [0x0007b] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.2.1.13/src/Xamarin.Mac/mcs/class/referencesource/mscorlib/system/runtime/serialization/objectmanager.cs:259 
  at System.Runtime.Serialization.ObjectManager.DoFixups () [0x0005a] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.2.1.13/src/Xamarin.Mac/mcs/class/referencesource/mscorlib/system/runtime/serialization/objectmanager.cs:925 
  at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize (System.Runtime.Remoting.Messaging.HeaderHandler handler, System.Runtime.Serialization.Formatters.Binary.__BinaryParser serParser, System.Boolean fCheck, System.Boolean isCrossAppDomain, System.Runtime.Remoting.Messaging.IMethodCallMessage methodCallMessage) [0x00077] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.2.1.13/src/Xamarin.Mac/mcs/class/referencesource/mscorlib/system/runtime/serialization/formatters/binary/binaryobjectreader.cs:181 
  at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize (System.IO.Stream serializationStream, System.Runtime.Remoting.Messaging.HeaderHandler handler, System.Boolean fCheck, System.Boolean isCrossAppDomain, System.Runtime.Remoting.Messaging.IMethodCallMessage methodCallMessage) [0x00099] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.2.1.13/src/Xamarin.Mac/mcs/class/referencesource/mscorlib/system/runtime/serialization/formatters/binary/binaryformatter.cs:197 
  at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize (System.IO.Stream serializationStream, System.Runtime.Remoting.Messaging.HeaderHandler handler, System.Boolean fCheck, System.Runtime.Remoting.Messaging.IMethodCallMessage methodCallMessage) [0x00000] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.2.1.13/src/Xamarin.Mac/mcs/class/referencesource/mscorlib/system/runtime/serialization/formatters/binary/binaryformatter.cs:173 
  at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize (System.IO.Stream serializationStream, System.Runtime.Remoting.Messaging.HeaderHandler handler, System.Boolean fCheck) [0x00000] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.2.1.13/src/Xamarin.Mac/mcs/class/referencesource/mscorlib/system/runtime/serialization/formatters/binary/binaryformatter.cs:118 
  at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize (System.IO.Stream serializationStream, System.Runtime.Remoting.Messaging.HeaderHandler handler) [0x00000] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.2.1.13/src/Xamarin.Mac/mcs/class/referencesource/mscorlib/system/runtime/serialization/formatters/binary/binaryformatter.cs:149 
  at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize (System.IO.Stream serializationStream) [0x00000] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.2.1.13/src/Xamarin.Mac/mcs/class/referencesource/mscorlib/system/runtime/serialization/formatters/binary/binaryformatter.cs:111 
  at System.Resources.ResourceReader.DeserializeObject (System.Int32 typeIndex) [0x00008] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.2.1.13/src/Xamarin.Mac/mcs/class/referencesource/mscorlib/system/resources/resourcereader.cs:838 
  at System.Resources.ResourceReader._LoadObjectV2 (System.Int32 pos, System.Resources.ResourceTypeCode& typeCode) [0x0035c] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.2.1.13/src/Xamarin.Mac/mcs/class/referencesource/mscorlib/system/resources/resourcereader.cs:808 
  at System.Resources.ResourceReader.LoadObjectV2 (System.Int32 pos, System.Resources.ResourceTypeCode& typeCode) [0x00000] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.2.1.13/src/Xamarin.Mac/mcs/class/referencesource/mscorlib/system/resources/resourcereader.cs:679 
  at System.Resources.ResourceReader.LoadObject (System.Int32 pos, System.Resources.ResourceTypeCode& typeCode) [0x00022] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.2.1.13/src/Xamarin.Mac/mcs/class/referencesource/mscorlib/system/resources/resourcereader.cs:588 
  at System.Resources.RuntimeResourceSet.GetObject (System.String key, System.Boolean ignoreCase, System.Boolean isString) [0x000be] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.2.1.13/src/Xamarin.Mac/mcs/class/referencesource/mscorlib/system/resources/runtimeresourceset.cs:331 
  at System.Resources.RuntimeResourceSet.GetObject (System.String key, System.Boolean ignoreCase) [0x00000] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.2.1.13/src/Xamarin.Mac/mcs/class/referencesource/mscorlib/system/resources/runtimeresourceset.cs:286 
  at System.Resources.ResourceManager.GetObject (System.String name, System.Globalization.CultureInfo culture, System.Boolean wrapUnmanagedMemStream) [0x00028] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.2.1.13/src/Xamarin.Mac/mcs/class/referencesource/mscorlib/system/resources/resourcemanager.cs:1404 
  at System.Resources.ResourceManager.GetObject (System.String name) [0x00000] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.2.1.13/src/Xamarin.Mac/mcs/class/referencesource/mscorlib/system/resources/resourcemanager.cs:1360 
  at FontEditor.MainForm.InitializeComponent () [0x0350e] in <ca161138f7504b689b385d55224d8623>:0 
  at FontEditor.MainForm..ctor (System.String FileName) [0x00006] in <ca161138f7504b689b385d55224d8623>:0 
  at (wrapper remoting-invoke-with-check) FontEditor.MainForm..ctor(string)
  at FontEditor.MainForm.Main (System.String[] args) [0x00018] in <ca161138f7504b689b385d55224d8623>:0 
@filipnavara
Copy link
Collaborator

Thanks for reporting it. We will give it a try and see what the issue is. The Mono code does the icon parsing in managed C# code while this implementation depends on the underlying CoreGraphics APIs. We recently had some examples of slightly malformed icons that failed to parse and it's possible the code may need some further tweaking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants