SecurityPermission error when instantiating media player
I'm using a Class Library exporting a function via COM. When calling this function from a JScript, it fails with the following error:
Error: System.Security.Permissions.SecurityPermission
Code: 8013150A
Here's the C# code of my library:
[ComVisible(true), Guid("B40EFE10-FC1B-43A0-ADA1-C923935F3537")]
public class ExodusGadget
{
private WindowsMediaPlayer wmp;
public void Play(string file)
{
wmp = new WindowsMediaPlayer();
//wmp.URL = file;
//wmp.controls.play();
}
}
And I'm using this JScript code (running in Windows 开发者_Python百科Scripting Host, i.e. without IE-related restrictions) to call it:
var obj = new ActiveXObject('ExodusGadget.ExodusGadget');
obj.play('somefile.mp3');
Calling other methods in my class which do not instantiate windows media player work fine. Thanks to microsofts unhelpful error messages I don't really have an idea what's going wrong.
Problem solved. It was due to the project and thus the DLL being on a network drive which windows considers as untrusted. Moving it to a local HDD fixed the problem.
精彩评论