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: Unable to cast DateTime to ValueTypeHolder #20

Open
asthomas opened this issue Jul 3, 2021 · 1 comment
Open

Exception: Unable to cast DateTime to ValueTypeHolder #20

asthomas opened this issue Jul 3, 2021 · 1 comment

Comments

@asthomas
Copy link

asthomas commented Jul 3, 2021

I created a MethodInvoker for DateTime.ToString(). When I call this as Invoker(DateTime.Now, null), I get this exception:

System.InvalidCastException: 'Unable to cast object of type 'System.DateTime' to type 'Fasterflect.Emitter.ValueTypeHolder'.'

Am I doing something wrong, or is this a bug in Fasterflect?

@Kladzey
Copy link

Kladzey commented Oct 11, 2021

Method WrapIfValueType solves the problem. Code

  DateTime.Now.WrapIfValueType().CallMethod("ToString")

works for me. Very strange, I cannot find any docs about the method and type ValueTypeHolder.

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