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

BUG? Exception when create EdmModel V7.1.0 #789

Closed
Ocean-Data opened this Issue Apr 8, 2017 · 8 comments

Comments

Projects
None yet
5 participants
@Ocean-Data

Ocean-Data commented Apr 8, 2017

Create EdmModel throw exception

EdmModel model = new EdmModel();

System.TypeInitializationException:“The type initializer for 'Microsoft.OData.Edm.Vocabularies.V1.CoreVocabularyModel' threw an exception.”

Internal exception:
ArgumentNullException: Value cannot be null.

Assemblies affected

ODatalib 7.1.0
.NetCore 1.1

@matjazmav

This comment has been minimized.

matjazmav commented Apr 8, 2017

Getting same exception on same environment.

@joshcomley

This comment has been minimized.

joshcomley commented Apr 8, 2017

I have exactly the same problem. Brand new project, one line of code:

EdmModel model = new EdmModel();

I get the exception.

@joshcomley

This comment has been minimized.

joshcomley commented Apr 9, 2017

This only happens when using the the package in a .NET Core context. It works fine in standard .NET.

To test this, simply create a new .NET Core Console app, add the reference and try to create a new EdmModel instance.

@AlanWong-MS AlanWong-MS self-assigned this Apr 10, 2017

@AlanWong-MS

This comment has been minimized.

Contributor

AlanWong-MS commented Apr 10, 2017

Thanks for the report. I'll take a look at this.

@robward-ms

This comment has been minimized.

Contributor

robward-ms commented Apr 11, 2017

Yep, totally a bug on our side. I've pulled 7.1.0 from Nuget.org and replace it with 7.1.1 which contains the Portable libs for Profile 259 but no longer contains the .Net Core libs. We'll post a patch to GitHub soon and make the .Net Core libs available via MyGet.

@joshcomley

This comment has been minimized.

joshcomley commented Apr 11, 2017

Thanks for confirming this, look forward to the fix :)

robward-ms added a commit to robward-ms/odata.net that referenced this issue Apr 11, 2017

This change fixes issue OData#789.
The EdmModel constructor was failing with System.TypeInitializationException:“The type initializer
for 'Microsoft.OData.Edm.Vocabularies.V1.CoreVocabularyModel' threw an exception.”

This was caused by the construction of the CoreVocabularyModel looking for embedded resources
that are not present in the .NetStandard version of Edm.

In addition to adding the embedded resources, the resource name are fully qualified
in NetStandard so addition code is added to find the proper name for the resource before
loading it.

The fix was tested by temporarily adding a unit test to validate the EdmModel constructor
as well as the unit test validation for CoreVocabularyModel and AlternateKeysVocabularyModel.
These tests are not included in this change as we need to invest in more than just these tests.
A future change will introduce a test suite for the NetStandard binary.

AlanWong-MS added a commit that referenced this issue Apr 11, 2017

This change fixes issue #789.
The EdmModel constructor was failing with System.TypeInitializationException:“The type initializer
for 'Microsoft.OData.Edm.Vocabularies.V1.CoreVocabularyModel' threw an exception.”

This was caused by the construction of the CoreVocabularyModel looking for embedded resources
that are not present in the .NetStandard version of Edm.

In addition to adding the embedded resources, the resource name are fully qualified
in NetStandard so addition code is added to find the proper name for the resource before
loading it.

The fix was tested by temporarily adding a unit test to validate the EdmModel constructor
as well as the unit test validation for CoreVocabularyModel and AlternateKeysVocabularyModel.
These tests are not included in this change as we need to invest in more than just these tests.
A future change will introduce a test suite for the NetStandard binary.
@robward-ms

This comment has been minimized.

Contributor

robward-ms commented Apr 11, 2017

You can find a nightly build Nuget package with an fix for this issue here (anything marked 7.2.0): https://www.myget.org/feed/Packages/odlnightly

@AlanWong-MS

This comment has been minimized.

Contributor

AlanWong-MS commented Apr 17, 2017

Closing this issue for now. We're actively working on a set of validations to ensure the official 7.2.0 doesn't come across this sort of problem. As robward-ms mentioned, you can check out our nightly build that contains the .NET Standard support if you'd like to try the libraries out early.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment