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

Open
rockfordlhotka opened this Issue Mar 22, 2018 · 4 comments

Comments

Projects
None yet
2 participants
@rockfordlhotka
Owner

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

This comment has been minimized.

Show comment Hide comment
@j055

j055 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).

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

This comment has been minimized.

Show comment Hide comment
@rockfordlhotka

rockfordlhotka Mar 31, 2018

Owner

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

Owner

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

This comment has been minimized.

Show comment Hide comment
@j055

j055 Mar 31, 2018

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

new-func
sln-func

j055 commented Mar 31, 2018

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

new-func
sln-func

@rockfordlhotka

This comment has been minimized.

Show comment Hide comment
@rockfordlhotka

rockfordlhotka Mar 31, 2018

Owner

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.

Owner

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.

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