I have a Windows Store application that uses a background task. The background task is stored in a Windows Runtime Component project. (This structure appears to be the only way to make background tasks work.)
In the background task project, I have some externally visible public methods that have return/parameter types that are my own classes rather than Windows Runtime classes.
For example:
public MyClass DoSomething()
{
return null;
}
When I build, I receive errors such as the following in relation to these methods:
Method 'X' returns 'Y', which is not a valid Windows Runtime type. Methods exposed to Windows Runtime must return only Windows Runtime types.
and
Method 'T' has parameter 'U' of type 'W'. 'W' is not a valid Windows Runtime parameter type.
I can understand what the errors are saying, but I haven't thought of a good way I can structure my code so that I meet these requirements.
Here are some things I have already considered:
- Changing the background task project to a Windows Store Class Library project. This allowed the use of the non-Windows Runtime types in the method signatures, but the background task no longer launched.
- Using a portable class library. This didn't work because it didn't have access to the Windows Runtime.
- For value types, I can break them up into
Tuple
s or multiple parameters, but this seems messy, less structured and less maintainable. I am strongly against this type of programming. - For classes, it seems that I might have to duplicate their logic across both applications. This is a huge maintainability problem.