Windows Media Player Designer View throwing CPU an

2019-08-09 11:08发布

I have a form called VideoForm which has a Windows Media Player called player.

public AxWMPLib.AxWindowsMediaPlayer player;

When I open VideoFrame.cs [Design] I get two errors:

Could not find type 'AxWMPLib.AxWindowsMediaPlayer'

The variable 'player' is either undeclared or was never assigned.

If I create a new form in my solution and try to add a Windows Media Player to it, I get this error:

Failed to create component 'AxHost' The error message follows: 'System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.

(with a ton of types listed below basically amounting to "stuff the toolbox needs to make a control")

I have tried: restarting Visual Studio, restarting my computer, deleting and re-importing the libraries, switching to 32, building, then switching back to 64 and building again, and manually finding the lib files on my machine.

But here's the weird part- if I close this solution, open another, add a Windows Media Player, compile to 64 bit, then close and reopen the original solution I don't get the errors!
EDIT: I do however get the following two errors when I attempt the above "hack":

Warning Processing COM reference "WMPLib" from path "C:\Windows\system32\wmp.dll". Type library importer encountered a property getter 'sessionPlaylistCount' on type 'WMPLib.IWMPNowPlayingHelperDispatch' without a valid return type. The importer will attempt to import this property as a method instead.

    and 

Processing COM reference "WMPLib" from path "C:\Windows\system32\wmp.dll". At least one of the arguments for 'IWMPGraphEventHandler.NotifyAcquireCredentials' cannot be marshaled by the runtime marshaler. Such arguments will therefore be passed as a pointer and may require unsafe code to manipulate.

I think I am getting a memory leak but am at a loss, and I see nothing at runtime in either Threads or GPU Threads windows.

I do not believe it is my code that is causing this, however if you want to see the code comment and I will add relevant parts.

1条回答
乱世女痞
2楼-- · 2019-08-09 11:29

I found solution to this problem:

{
Warning 1 Processing COM reference "WMPLib" from path "C:\Windows\system32\wmp.dll". Type library importer encountered a property getter 'sessionPlaylistCount' on type 'WMPLib.IWMPNowPlayingHelperDispatch' without a valid return type. The importer will attempt to import this property as a method instead.

Warning 2 Processing COM reference "WMPLib" from path "C:\Windows\system32\wmp.dll". At least one of the arguments for 'IWMPGraphEventHandler.NotifyAcquireCredentials' cannot be marshaled by the runtime marshaler. Such arguments will therefore be passed as a pointer and may require unsafe code to manipulate.
}

i must edit my word ! If you receive these error This does not mean that your application will not run But if you compile your program does not run setup file on Windows old You can set the following: set your program framework to 4 client version and set your platform of program to X86 and creat your installer on framework 4 client

查看更多
登录 后发表回答