When building an “Orleans” Project you might get following error.
ERROR -- Exception caught --
Exception = System.InvalidOperationException: This operation is only valid on generic types.
at System.RuntimeType.GetGenericTypeDefinition()
at GrainClientGenerator.GrainInterfaceData.GetPromptType(Type type)
at GrainClientGenerator.InvokerGeneratorBasic.<>c__DisplayClass18.<GetPropertyClasses>b__14(KeyValuePair`2 p)
at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
at GrainClientGenerator.InvokerGeneratorBasic.GetPropertyClasses(GrainInterfaceData grainInterfaceData, Action`1 referred)
at GrainClientGenerator.GrainClientGenerator.ProcessInputGrainAssembly(Assembly grainAssembly, Dictionary`2 namespaceDictionary, String outputAssemblyName)
at GrainClientGenerator.GrainClientGenerator.CreateGrainClient(FileInfo inputLib, FileInfo outputLib, String sourcesDir, FileInfo keyFile, List`1 referencedAssemblyPaths, List`1 defines, Boolean compileFromSources, String codeGenFile)
at GrainClientGenerator.GrainClientGenerator.CreateGrainClient(FileInfo inputLib, FileInfo outputLib, String sourcesDir, FileInfo keyFile, List`1 referencedAssemblyPaths, List`1 defines, Boolean compileFromSources, String codeGenFile)
at GrainClientGenerator.GrainClientGenerator.CreateGrainClientAssembly(Boolean compileFromSources, FileInfo inputLib, FileInfo outputLib, String sourcesDir, FileInfo signingKey, List`1 referencedAssemblies, List`1 sourcesFiles, List`1 defines, Boolean shouldMerge, String codeGenFile)
ERROR -- Exception caught -- System.InvalidOperationException: This operation is only valid on generic types.
at System.RuntimeType.GetGenericTypeDefinition()
at GrainClientGenerator.GrainInterfaceData.GetPromptType(Type type)
at GrainClientGenerator.InvokerGeneratorBasic.<>c__DisplayClass18.<GetPropertyClasses>b__14(KeyValuePair`2 p)
at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
at GrainClientGenerator.InvokerGeneratorBasic.GetPropertyClasses(GrainInterfaceData grainInterfaceData, Action`1 referred)
at GrainClientGenerator.GrainClientGenerator.ProcessInputGrainAssembly(Assembly grainAssembly, Dictionary`2 namespaceDictionary, String outputAssemblyName)
at GrainClientGenerator.GrainClientGenerator.CreateGrainClient(FileInfo inputLib, FileInfo outputLib, String sourcesDir, FileInfo keyFile, List`1 referencedAssemblyPaths, List`1 defines, Boolean compileFromSources, String codeGenFile)
at GrainClientGenerator.GrainClientGenerator.CreateGrainClient(FileInfo inputLib, FileInfo outputLib, String sourcesDir, FileInfo keyFile, List`1 referencedAssemblyPaths, List`1 defines, Boolean compileFromSources, String codeGenFile)
at GrainClientGenerator.GrainClientGenerator.CreateGrainClientAssembly(Boolean compileFromSources, FileInfo inputLib, FileInfo outputLib, String sourcesDir, FileInfo signingKey, List`1 referencedAssemblies, List`1 sourcesFiles, List`1 defines, Boolean shouldMerge, String codeGenFile)
at GrainClientGenerator.GrainClientGenerator.RunMain(String[] args)
I agree that the error is very consuming. In fact it doesn’t say anything about source of the failure. Fortunately, solution is easy.
Take a look on following example:
public interface IChild : Orleans.IGrain
{
Task AddParent(IParent parent);
Task Parent { get; }
}
The code shown above cause the error. When you work with properties, they have to always return a generic Task, like Task<T>.
The property above does not fulfill this rule. The code below is correct one:
public interface IChild : Orleans.IGrain
{
Task AddParent(IParent parent);
Task<IParent> Parent { get; }
}
Now, when you now the solution, the error is understandable:
Exception = System.InvalidOperationException: This operation is only valid on generic types. Isnt’ it? :)
Posted
Jun 10 2014, 07:20 AM
by
Damir Dobric