B
b_jooorn
Hi,
I have an Active X Control that is supposed to run in Windows Media
Center. This control causes an error (something along the lines of
"Not trusted control...") and I found out that I need to implement the
IObjectSafety Interface to give Media Center a way to check whether my
control is safe or not.
Alright, now I basically used this code for the interface:
/// <summary>
/// See Internet SDK, IObjectSafety.
/// </summary>
[Flags]
public enum ObjectSafetyFlags : int
{
/// <summary>
/// Caller of interface may be untrusted
/// </summary>
INTERFACESAFE_FOR_UNTRUSTED_CALLER = 1,
/// <summary>
/// Data passed into interface may be untrusted
/// </summary>
INTERFACESAFE_FOR_UNTRUSTED_DATA = 2,
/// <summary>
/// Object knows to use IDispatchEx.
/// </summary>
INTERFACE_USES_DISPEX = 4,
/// <summary>
/// Objects knows to use IInternetHostSecurityManager.
/// </summary>
INTERFACE_USES_SECURITY_MANAGER = 8,
/// <summary>
/// Flags combination.
/// </summary>
SafeForScripting = INTERFACESAFE_FOR_UNTRUSTED_CALLER |
INTERFACESAFE_FOR_UNTRUSTED_DATA
}
/// <summary>
/// See Internet SDK, IObjectSafety.
/// </summary>
[ComVisible(true)]
[ComImport]
[Guid("CB5BDC81-93C1-11cf-8F20-00805F2CD064")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IObjectSafety
{
void GetInterfaceSafetyOptions(ref Guid riid, out int
supportedOptions, out int enabledOptions);
void SetInterfaceSafetyOptions(ref Guid riid, int
optionSetMask, int enabledOptions);
}
Implementation:
[ComVisible(true)]
########### Question ################
Where do I get this GUID from???
--> [Guid("773ecc45-670f-45d0-8780-2ab71c654a21")] <--
public class MyUserControl : UserControl, IObjectSafety
{
...
public void GetInterfaceSafetyOptions(ref Guid riid, out int
supportedOptions, out int enabledOptions)
{
supportedOptions = enabledOptions = (int)
ObjectSafetyFlags.SafeForScripting;
}
public void SetInterfaceSafetyOptions(ref Guid riid, int
optionSetMask, int enabledOptions)
{
}
My question now is, where do I get the Guid from that is mentioned in
the above interface?
I think it's an IID (Interface ID), but have no clue how or where to
get one of those...
Since I have seen many posts with these IIDs in it, I'm hoping that
someone can help me out.
Thanks in advance,
Steve
I have an Active X Control that is supposed to run in Windows Media
Center. This control causes an error (something along the lines of
"Not trusted control...") and I found out that I need to implement the
IObjectSafety Interface to give Media Center a way to check whether my
control is safe or not.
Alright, now I basically used this code for the interface:
/// <summary>
/// See Internet SDK, IObjectSafety.
/// </summary>
[Flags]
public enum ObjectSafetyFlags : int
{
/// <summary>
/// Caller of interface may be untrusted
/// </summary>
INTERFACESAFE_FOR_UNTRUSTED_CALLER = 1,
/// <summary>
/// Data passed into interface may be untrusted
/// </summary>
INTERFACESAFE_FOR_UNTRUSTED_DATA = 2,
/// <summary>
/// Object knows to use IDispatchEx.
/// </summary>
INTERFACE_USES_DISPEX = 4,
/// <summary>
/// Objects knows to use IInternetHostSecurityManager.
/// </summary>
INTERFACE_USES_SECURITY_MANAGER = 8,
/// <summary>
/// Flags combination.
/// </summary>
SafeForScripting = INTERFACESAFE_FOR_UNTRUSTED_CALLER |
INTERFACESAFE_FOR_UNTRUSTED_DATA
}
/// <summary>
/// See Internet SDK, IObjectSafety.
/// </summary>
[ComVisible(true)]
[ComImport]
[Guid("CB5BDC81-93C1-11cf-8F20-00805F2CD064")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IObjectSafety
{
void GetInterfaceSafetyOptions(ref Guid riid, out int
supportedOptions, out int enabledOptions);
void SetInterfaceSafetyOptions(ref Guid riid, int
optionSetMask, int enabledOptions);
}
Implementation:
[ComVisible(true)]
########### Question ################
Where do I get this GUID from???
--> [Guid("773ecc45-670f-45d0-8780-2ab71c654a21")] <--
public class MyUserControl : UserControl, IObjectSafety
{
...
public void GetInterfaceSafetyOptions(ref Guid riid, out int
supportedOptions, out int enabledOptions)
{
supportedOptions = enabledOptions = (int)
ObjectSafetyFlags.SafeForScripting;
}
public void SetInterfaceSafetyOptions(ref Guid riid, int
optionSetMask, int enabledOptions)
{
}
My question now is, where do I get the Guid from that is mentioned in
the above interface?
I think it's an IID (Interface ID), but have no clue how or where to
get one of those...
Since I have seen many posts with these IIDs in it, I'm hoping that
someone can help me out.
Thanks in advance,
Steve