error MIDL2311 : statements outside library block are illegal in mktyplib compatability mode

解决办法:

1. Do not use the /mktyplib203 switch unless you have to deal with legacy code dating back to mktyplib ver.2.03.

2.  In the .odl file, put the following inside the library block:

     #include <olectl.h>

参考资料:

https://social.msdn.microsoft.com/Forums/en-US/5ae2ed97-66cc-4dd8-ad88-4245f93d7628/error-midl2311-statements-outside-library-block-are-illegal-in-mktyplib-compatability-mode?forum=vcgeneral

原文地址:https://www.cnblogs.com/qrlozte/p/4995462.html