Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Better exception when serialized class lacks default constructor #10

Open
oskarb opened this issue Dec 28, 2010 · 2 comments
Open

Better exception when serialized class lacks default constructor #10

oskarb opened this issue Dec 28, 2010 · 2 comments

Comments

@oskarb
Copy link

oskarb commented Dec 28, 2010

Over DBus I call a method that takes a parameter of type MyClass. This class has no default constructor. I get a NullReferenceException which is not helpful at all!

System.: Object reference not set to an instance of an object
at System.Reflection.Emit.ILGenerator.Emit (OpCode opcode, System.Reflection.ConstructorInfo con) [0x0001b] in /home/oskar/mono24/mono-2.6.7/mono-2.6.7/mcs/class/corlib/System.Reflection.Emit/ILGenerator.cs:536
at DBus.TypeImplementer.GenStructReader (System.Reflection.Emit.ILGenerator ilg, System.Type type) [0x00014] in /home/oskar/mono24/mono-2.6.7/dbus-sharp-0.7.0/src/TypeImplementer.cs:298
[... snipped lots of stack frames ...]

I think TypeImplementer.GenStructReader() should check for null return value from GetConstructor() and throw a proper exception with a more helpful error message.

Also, this problem does not show until actually trying to receive a message containing the offending type. It would perhaps be better to check for this already when the object is registered with the connection, to become aware of the problem earlier. Perhaps this is a bit more complex to achieve though.

@bnbot
Copy link

bnbot commented Jun 9, 2021

Issues go stale after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@minkhantaunh
Copy link

thank

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

No branches or pull requests

3 participants