Skip to content

Make Exception serializable #22

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

Closed
huan086 opened this issue Nov 6, 2016 · 5 comments
Closed

Make Exception serializable #22

huan086 opened this issue Nov 6, 2016 · 5 comments

Comments

@huan086
Copy link

huan086 commented Nov 6, 2016

I'm running JavaScript in my Entity Framework seed method. When an exception occurs, it throws
Type 'JavaScriptEngineSwitcher.Core.JsEngineLoadException' in assembly 'JavaScriptEngineSwitcher.Core, Version=2.0.3.0, Culture=neutral, PublicKeyToken=c608b2a8cc9e4472' is not marked as serializable.

So make exceptions serializable. See
https://blogs.msdn.microsoft.com/agileer/2013/05/17/the-correct-way-to-code-a-custom-exception-class/

@Taritsyn
Copy link
Owner

Taritsyn commented Nov 6, 2016

Hello, Huan!

I will fix this problem in the next release.

You have found the cause of the JsEngineLoadException? What JS engine are you using?

@huan086
Copy link
Author

huan086 commented Nov 6, 2016

JsEngineLoadException was due to the new nuget package not having the native DLLs bundled by default. Installed the 2 native packages and the error went away.

Using ClearScript V8

@Taritsyn
Copy link
Owner

Taritsyn commented Nov 6, 2016

OK

@Daniel15
Copy link

Daniel15 commented Nov 6, 2016

Note that .NET Core doesn't have binary serialization, so you need to use conditional comments like this to only include the Serializable attribute (and constructor with SerializationInfo and StreamingContext) on .NET Framework and not .NET Core:

#if NET40 || NET45
    [Serializable]
#endif

eg. see https://github.com/reactjs/React.NET/blob/89bc9cbecef5e549f746d645d42706aa3a6d3219/src/React.Core/Exceptions/BabelException.cs#L18

@Taritsyn
Copy link
Owner

Taritsyn commented Nov 8, 2016

Hello, Huan!

In JavaScript Engine Switcher 2.1.2 fixed this error.

@huan086 huan086 closed this as completed Nov 9, 2016
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

3 participants