Frage

I thought this problem was fixed. I'm using Visual Studio 2013 and it is Entity Framework 6.1. I get the error message: PublicKeyToken=xxxxxx is not marked as serializable.

I thought this was fixed. Is it broken again and if so, is there a workaround?

Thanks.

Here is the complete error message when trying to install into a win32 C++ console application. (Built with default settings, no other adds to new build.) Error: Type 'Microsoft.VisualStudio.Project.VisualC.VCProjectEngine.VCProjectShim' in Assembly 'Microsoft.VisualStudio.Project.VisualC.VCProjectEngine, Version=12.0.0.0,Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is not marked as serializable.

Here is the complete error message when trying to install into a C++ CLR: (Actually, it's the exact same error message.)

Here is the complete error message when trying to install into a General Empty C++ Project: (Again, same error message.)

War es hilfreich?

Lösung

Okay, I can finally figure out what you are doing. You are trying to run Nuget to download and install the Entity Framework into a C++ project. Yes, that's going to be a fail-whale. Nuget acquired the ability to install C++ libraries at version 2.5, but that only works for native libraries. Pure C++, not managed code like EF. Being a relatively new feature, it doesn't do anything to stop you from getting it wrong, it doesn't filter the available packages to the kind that can work in a C++ project.

The step that fails is the final one, download and copying files work okay but then Nuget runs a Powerscript script to modify the project properties. Which, for EF, was written to work in a C# or VB.NET project. The VS extension model for C++ projects (implemented by the VCProjectEngine class as reported in the error message) is too different to permit that script to complete successfully.

Do keep in mind that the odds of using EF in a native C++ projects are zero. You'll only have a smallish shot at it in a C++/CLI project. Starting with a project template in the CLR node is a required first step.

The next one is to fool the Nuget installer, add a dummy C# project to your solution and run Nuget to get EF installed into that project. You'll see it adding an app.config file to the project, you need to do the same in your C++/CLI project. And it adds two EF assemblies that you also need to add to your C++/CLI project:

  • Right-click the project in the Solution Explorer window, Properties
  • Select Common Properties + References
  • Click the Add New Reference button
  • Click the Browse button
  • Navigate to the dummy C# project's packages\EntityFramework.6.1.0\lib\net45 directory
  • Select EntityFramework.dll you see there
  • Repeat to add EntityFramework.SqlServer.dll there.

Be sure to write C++/CLI code to use it. Beware that you'll have a Eskimo's chance to find any. The much saner approach is to create a C# library that uses EF and use that library in a C++/CLI project.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top