{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/orleans/issues/1064","labels_url":"https://api.github.com/repos/dotnet/orleans/issues/1064/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/orleans/issues/1064/comments","events_url":"https://api.github.com/repos/dotnet/orleans/issues/1064/events","html_url":"https://github.com/dotnet/orleans/issues/1064","id":118444534,"number":1064,"title":"Serialization fails when grain methods use abstract types from external libraries","user":{"login":"randa1","id":3209338,"avatar_url":"https://avatars.githubusercontent.com/u/3209338?v=3","gravatar_id":"","url":"https://api.github.com/users/randa1","html_url":"https://github.com/randa1","followers_url":"https://api.github.com/users/randa1/followers","following_url":"https://api.github.com/users/randa1/following{/other_user}","gists_url":"https://api.github.com/users/randa1/gists{/gist_id}","starred_url":"https://api.github.com/users/randa1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/randa1/subscriptions","organizations_url":"https://api.github.com/users/randa1/orgs","repos_url":"https://api.github.com/users/randa1/repos","events_url":"https://api.github.com/users/randa1/events{/privacy}","received_events_url":"https://api.github.com/users/randa1/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-11-23T18:41:16Z","updated_at":"2015-11-24T04:31:08Z","closed_at":null,"body":"Hello all,\r\n\r\nWe have a grain which accepts a parameter with an abstract type, which is loaded from an external library which is Orleans agnostic (a nuget used by several systems in our deployment). Until lately, everything worked fine. When we got the latest master branch the behavior broke and we can no longer invoke this method.\r\n\r\nI've created a test for it (on the Orleans solution) here: https://github.com/randa1/orleans/commit/13750fae5e6748aa132a74a58f47b6c99f489f24\r\n\r\nI've investigated and it seems that a change in assembly loading is causing it. In previous versions, all types of each loaded assembly would be registered in the `SerializationManager`:\r\n``` c#\r\n        private static void OnAssemblyLoad(object sender, AssemblyLoadEventArgs args)\r\n        {\r\n            // Old code. All loaded assemblies would get here and all types will be registered\r\n            FindSerializationInfo(args.LoadedAssembly);\r\n        }\r\n```\r\n\r\nIn the new code, which is the current master branch, this has changed and the `AssemblyProcessor` class was added to handle the callback:\r\n``` c#\r\n        private static void ProcessAssembly(Assembly assembly)\r\n        {\r\n            // If the assembly is loaded for reflection only or it does not reference Orleans, avoid processing it.\r\n            if (assembly.ReflectionOnly || !TypeUtils.IsOrleansOrReferencesOrleans(assembly))\r\n            {\r\n                return;\r\n            }\r\n            // rest of code...\r\n        }\r\n```\r\n\r\nSince our external library assembly is loaded with `ReflectionOnly` set to `true` and does not reference orleans, the types are not registered.\r\n\r\nFrom what I've seen it only happens for abstract types, since for concrete types the codegen creates a serializer, which is registered to the `SerializationManager` by some other code path.\r\n\r\nPaging @ReubenBond too as the `AssemblyProcessor` changes were made by him :)\r\n\r\nThanks,\r\nRan"},"comment":{"url":"https://api.github.com/repos/dotnet/orleans/issues/comments/159147051","html_url":"https://github.com/dotnet/orleans/issues/1064#issuecomment-159147051","issue_url":"https://api.github.com/repos/dotnet/orleans/issues/1064","id":159147051,"user":{"login":"gabikliot","id":10171207,"avatar_url":"https://avatars.githubusercontent.com/u/10171207?v=3","gravatar_id":"","url":"https://api.github.com/users/gabikliot","html_url":"https://github.com/gabikliot","followers_url":"https://api.github.com/users/gabikliot/followers","following_url":"https://api.github.com/users/gabikliot/following{/other_user}","gists_url":"https://api.github.com/users/gabikliot/gists{/gist_id}","starred_url":"https://api.github.com/users/gabikliot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gabikliot/subscriptions","organizations_url":"https://api.github.com/users/gabikliot/orgs","repos_url":"https://api.github.com/users/gabikliot/repos","events_url":"https://api.github.com/users/gabikliot/events{/privacy}","received_events_url":"https://api.github.com/users/gabikliot/received_events","type":"User","site_admin":false},"created_at":"2015-11-24T04:31:08Z","updated_at":"2015-11-24T04:31:08Z","body":"Can try adding [Serializable] attribute to this abstract type? I think it might solve the problem."}}