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

OnDeserialized attribute from NS2 causes runtime error in full .NET #822

Closed
rockfordlhotka opened this issue Mar 22, 2018 · 6 comments
Closed
Labels
Milestone

Comments

@rockfordlhotka
Copy link
Member

@rockfordlhotka rockfordlhotka commented Mar 22, 2018

Several CSLA base classes use the OnDeserialized attribute to be notified when the BinaryFormatter or NDCS has completed deserializing the object graph.

Unfortunately at the moment there's a conflict between this attribute in netstandard 2.0 and full .NET. So if you use this attribute in an NS2 assembly and then try to reference and run that assembly from within a full .NET runtime (ASP.NET, Windows Forms, WPF, etc.) you'll get a runtime exception because the types don't match.

Until this issue is resolved within full .NET CSLA needs to maintain a set of NuGet packages (and assemblies) that target full .NET separately from netstandard.

This is documented by dotnet/standard#300 in the Microsoft .NET repo.

@j055
Copy link
Contributor

@j055 j055 commented Mar 31, 2018

This isn't just full .NET which is affected. If you create an Azure Function project targeting .NET Core and install CSLA-Core-NS, you cannot build the project because TypeLoadException is thrown.

System.TypeLoadException: Type 'Csla.Core.ManagedObjectBase' in assembly 'Csla, Version=4.7.100.0, Culture=neutral, PublicKeyToken=93be5fdc093e4c30' has method 'OnDeserializedHandler' with an incorrect signature for the serialization attribute that it is decorated with.
   at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)
   at System.Reflection.RuntimeAssembly.GetExportedTypes()
   at MakeFunctionJson.FunctionJsonConverter.TryGenerateFunctionJsons()
   at MakeFunctionJson.FunctionJsonConverter.TryRun()

As far as I can tell you can't use CSLA in any flavour of an Azure Function Project if you want to use the DataPortal (local or otherwise).

@rockfordlhotka
Copy link
Member Author

@rockfordlhotka rockfordlhotka commented Mar 31, 2018

Azure Functions use full. NET so an NS assembly won't work. I don’t know why the full. NET version is having issues.

@j055
Copy link
Contributor

@j055 j055 commented Mar 31, 2018

It's a preview but the tooling certainly suggests that it uses .NET Core.

new-func
sln-func

@rockfordlhotka
Copy link
Member Author

@rockfordlhotka rockfordlhotka commented Mar 31, 2018

I haven't used the latest. The key with CSLA at this point is that you use CSLA-Core when running in full dotnet and CSLA-Core-NS when running in netcore.

@rockfordlhotka
Copy link
Member Author

@rockfordlhotka rockfordlhotka commented Aug 20, 2018

Sounds like the issue has been resolved in .NET 4.7.2.
dotnet/standard#300 (comment)

Which now begs the issue of whether I can unravel the mess of NuGet packages I've created such that when everyone eventually starts using 4.7.2 we can get back to simply using CSLA-Core...

@rockfordlhotka rockfordlhotka added this to the 4.8.100 milestone Aug 24, 2018
@rockfordlhotka
Copy link
Member Author

@rockfordlhotka rockfordlhotka commented Aug 24, 2018

Upon further review, and the changes made in #927, no work is required to resolve this issue.

For the next several years the CSLA-Core package will contain one or more .NET Framework assemblies along with .NET Standard assemblies. At no point in the foreseeable future will any .NET Framework app end up using the NS2 assembly.

Once all CSLA .NET users are on at least .NET Framework version 4.7.2 many years will have passed. But at that time perhaps the CSLA-Core package can contain just the NS assembly(ies).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.