سؤال

The development platform for our C# project is currently Visual Studio 2010, and my development computer is Windows 7.

I need to implement some code for a Windows interface that is part of Mbnapi.tlb, and is only available on Windows 8.

When I check on my computer, the Windows 8 version of this file is present (see below). enter image description here

So, according to help that I got from a previous SO question, I removed the reference to Mbnapi.tlb from my project, and added a reference to C:\Program Files\Windows Kits\8.0\lib\win8\um\x64\Mbnapi.tlb.

The problem is, that it doesn't seem to work. I saved the change, and then tried to access an API function that is only available in Windows 8, and it is not visible.

When I opened the project in VS 2012 on a Windows 8 computer and made the same reference change to the newer Mbnapi.tlb, I was able to see the Windows 8 functionality in Visual Studio.

Because the Windows 8 versions of the .tlbs are available in my development environment, I assume that I ought to be able to use them, even for functionality that can't be tested on Windows 7.

My question is: Does anyone know how to get round this problem, so that I can develop for Windows 8 on a Windows 7 computer?

هل كانت مفيدة؟

المحلول

This cannot work, adding a reference to a .tlb file causes Visual Studio to use a <COMReference> element in your project file that states the type library {guid}. Not the file. You'll inevitably get the registered Win7 version of the type library, not the Win8 version. So you'll see the Win8 additions missing. This is a Good Thing, it ensures your program can actually be debugged and tested.

You must instead run Tlbimp.exe on the Win8 machine to convert the type library to an interop library. You'll get MbnApi.dll, copy it to your Win7 machine into your project directory and add a reference to it.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top