Home
Blogs
Forums
Files


Welcome to The Green Button          Sign in | Join | Help

IObjectSafety - implementing in vb.net

Last post 03-27-2008, 5:37 AM by Scott.Weaver. 12 replies.
Sort Posts: Previous Next
  •  10-20-2005, 4:37 AM 76238

    IObjectSafety - implementing in vb.net

    Hi, i need to implement the IObjectSafety interface for a vb.net COM .dll which is being used for an MCE app. I've created this in a module file (Config.vb):

    Public Interface IObjectSafety
       
    Sub GetInterfaceSafetyOptions(ByRef riid As Guid, ByRef supportedOptions As Integer, ByRef enabledOptions As Integer)

        Sub SetInterfaceSafetyOptions(ByRef riid As Guid, ByVal optionSetMask As Integer, ByVal enabledOptions As Integer)
    End Interface

    Public Enum ObjectSafetyFlags As Integer
       INTERFACESAFE_FOR_UNTRUSTED_CALLER = 1
       INTERFACESAFE_FOR_UNTRUSTED_DATA = 2
       INTERFACE_USES_DISPEX = 4
       INTERFACE_USES_SECURITY_MANAGER = 8
       SafeForScripting = INTERFACESAFE_FOR_UNTRUSTED_CALLER
    Or INTERFACESAFE_FOR_UNTRUSTED_DATA
    End Enum

    and for each class i implement it using:

    Public Class Item
         
    Implements IObjectSafety

    and the following is within each class:

    Public Sub GetInterfaceSafetyOptions(ByRef riid As System.Guid, ByRef supportedOptions As Integer, ByRef enabledOptions As Integer) Implements Config.IObjectSafety.GetInterfaceSafetyOptions
        supportedOptions = ObjectSafetyFlags.SafeForScripting
        enabledOptions = ObjectSafetyFlags.SafeForScripting
    End Sub

    Public Sub SetInterfaceSafetyOptions(ByRef riid As System.Guid, ByVal optionSetMask As Integer, ByVal enabledOptions As Integer) Implements Config.IObjectSafety.SetInterfaceSafetyOptions

    End Sub

    but when the .dll is invoke within the HTML page on the MCE machine, IE still says it's unsafe so im assuming it's not implemented properly. So has anyone else successfully done this in vb.net and if so could you let me know how?

    Thanks in advance.

    Dan.

  •  10-22-2005, 7:32 PM 76766 in reply to 76238

    RE: IObjectSafety - implementing in vb.net

    Searching for the same subject I found this http://support.microsoft.com/default.aspx?scid=kb;en-us;Q182598

    give it a try...

     

    Cris

     

  •  10-23-2005, 9:22 AM 76820 in reply to 76238

    RE: IObjectSafety - implementing in vb.net

    Hello,

    I have implemented this. Here is a template for everyone.

    Dean

     


    _________________________________________________________

    Take 10 minutes out to do nothing! -  www.10footgames.net

    • *NEW* - mceLights V1.0
    • *NEW* - mcePeaks V2.0

     

  •  10-23-2005, 9:24 AM 76821 in reply to 76238

    RE: IObjectSafety - implementing in vb.net

    Don't forget to sign your code!

    _________________________________________________________

    Take 10 minutes out to do nothing! -  www.10footgames.net

    • *NEW* - mceLights V1.0
    • *NEW* - mcePeaks V2.0

     

  •  10-24-2005, 3:18 AM 76980 in reply to 76238

    RE: IObjectSafety - implementing in vb.net

    Dean, thanks for the template, have got my project working correctly now, very much appreciated!

    Thanks, Dan.

  •  01-09-2006, 3:24 AM 89262 in reply to 76238

    RE: IObjectSafety - implementing in vb.net

    <QUOTE>Is this the c# equivalent?

    http://blogs.msdn.com/infopath/archive/2005/04/15/408728.aspx

     

    THX

     

    Woops used the wrong post button.  Belongs to this thread

    http://www.thegreenbutton.com/community/shwmessage.aspx?ForumID=30&MessageID=137195</QUOTE>

    TThomas, This is the same thing.

    Hoof

     


    _________________________________________________________

    Take 10 minutes out to do nothing! -  www.10footgames.net

    • *NEW* - mceLights V1.0
    • *NEW* - mcePeaks V2.0

     

  •  05-04-2006, 9:49 PM 112711 in reply to 76820

    Re: RE: IObjectSafety - implementing in vb.net

    I am looking for the template in VB.NET

    Thanks in advance.

  •  05-18-2006, 7:24 AM 115064 in reply to 112711

    Re: RE: IObjectSafety - implementing in vb.net

    Where can I download the template?
  •  06-20-2006, 5:37 AM 121509 in reply to 76820

    Re: RE: IObjectSafety - implementing in vb.net

    I can not see the template. Is it still available?
  •  09-11-2006, 2:29 PM 137048 in reply to 121509

    Re: RE: IObjectSafety - implementing in vb.net

    Here is an easier approach.

    1- Create a module file and call it objsafe

    2- Copy and paste the following code to the module

    Imports System.Runtime.InteropServices

    <ComImport()> _

    <Guid("CB5BDC81-93C1-11CF-8F20-00805F2CD064")> _

    <InterfaceType(ComInterfaceType.InterfaceIsIUnknown)> _

    Public Interface IObjectSafety

    Function GetInterfaceSafetyOptions(ByRef iid As Guid, ByRef pdwSupportedOptions As Integer, ByRef pdwEnabledOptions As Integer) As Integer

    Function SetInterfaceSafetyOptions(ByRef iid As Guid, ByVal dwOptionSetMask As Integer, ByVal dwEnabledOptions As Integer) As Integer

    End Interface

     

    3- Now make your class inherits the interface as follows:

    Public Class MyClass

    Implements IObjectSafety

     

    and also add the folloiwng definitions inside your class:

    ' Constants for implementation of the IObjectSafety interface.

    Private Const INTERFACESAFE_FOR_UNTRUSTED_CALLER As Integer = &H1

    Private Const INTERFACESAFE_FOR_UNTRUSTED_DATA As Integer = &H2

     

    4- Implement the two interface methods as follows:

    Public Function GetInterfaceSafetyOptions(ByRef iid As Guid, ByRef pdwSupportedOptions As Integer, ByRef pdwEnabledOptions As Integer) As Integer Implements IObjectSafety.GetInterfaceSafetyOptions

    pdwSupportedOptions = INTERFACESAFE_FOR_UNTRUSTED_CALLER Or INTERFACESAFE_FOR_UNTRUSTED_DATA

    pdwEnabledOptions = INTERFACESAFE_FOR_UNTRUSTED_CALLER Or INTERFACESAFE_FOR_UNTRUSTED_DATA

    Return 0

    End Function

     

    Public Function SetInterfaceSafetyOptions(ByRef iid As Guid, ByVal dwOptionSetMask As Integer, ByVal dwEnabledOptions As Integer) As Integer Implements IObjectSafety.SetInterfaceSafetyOptions

    Return 0

    End Function

     

    Now you class become safety for scripting and initializing ready.

    Feras

  •  03-11-2008, 2:56 PM 249497 in reply to 137048

    Re: RE: IObjectSafety - implementing in vb.net

    when i run the above code, i still get the ActiveX unsafe warning.  Has anyone been able to get IobjectSafety successfully working in .NET?  either VB or C# solutions are fine.

  •  03-22-2008, 10:48 AM 251730 in reply to 249497

    Re: RE: IObjectSafety - implementing in vb.net

    Check the dates before you post. This is way old and will not work.
  •  03-27-2008, 5:37 AM 252773 in reply to 76820

    Re: RE: IObjectSafety - implementing in vb.net

    Dean,

    The template no longer appears as part of this post. Could you please repost it

    Thanks

    Scott

View as RSS news feed in XML
About TGB | Advertise | Link To Us | Donate | Terms Of Use | Privacy Policy
© 2003-2007 The Green Button, Inc. - All Rights Reserved