Take the 2-minute tour ×

Is there a possibility to make the compiler not check functions and methods that aren't used? I'm working on an app that relies on code (in C#), in which members of the system.windows.forms.dll are used in some functions and methods. For instance:

protected IWin32Window parentWindow;
public virtual UserControl GetFirmwareInformation()

My app doesn't use this members, but it tries to load the dll anyway, and doesn't succeed, because, as I know, you can't use this dll. Now I'm looking for a workaround, because I can't throw the "forms-using methods" away. One solution would be, to use precompiler directives, but I hope, that there is a more elegant way, because in the solution is also another c# desktop-program that can use the forms-dll.

Is there another solution?

share|improve this question
Can't you just create a dummy assembly with these types? –  Hans Passant Oct 11 '12 at 15:06
add comment

1 Answer

up vote 0 down vote accepted

One thing you could do is to ship some files with your MonoDroid app which implement stubbed out versions of the missing interfaces, classes, enums and methods.

A neater solution might be to split those dependencies out of your source code somehow - either using some form of interface/injection or just simply using partial classes to split your code between multiple files. I'd personally go for some injection mechanism - but that's because I find using partial classes like that is quite similar to using #define.

share|improve this answer
The dummy assemblies are a good idea, also is the interface/injection solution, but this can be very time consuming. Another idea: Can I build a apk file myself, that contains the dll's I need, because from my point of view, the main problem is the compiling procedure, which checks the types and members even if they aren't used in my program. –  Netbus Oct 15 '12 at 8:33
add comment

Your Answer


