vb.net error while registering evevents

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • shivkumar2004@gmail.com

    #1

    vb.net error while registering evevents

    Hi!,

    I am developing a chat system using vb.net in vs 2005. I am getting
    the following error while registering the events.

    error details: System.InvalidO perationExcepti on was unhandled
    Message="An error occurred creating the form. See
    Exception.Inner Exception for details. The error is: Type
    System.Delegate SerializationHo lder and the types derived from it (such
    as System.Delegate SerializationHo lder) are not permitted to be
    deserialized at this security level."
    Source="ChatApp lication"
    StackTrace:
    at ChatApplication .My.MyProject.M yForms.Create__ Instance__[T](T
    Instance) in 17d14f5c-a337-4978-8281-53493378c1071.v b:line 190
    at ChatApplication .My.MyProject.M yForms.get_Clie nt()
    at ChatApplication .Client.Main() in C:\tests\chatSo l
    \ChatApplicatio n\Client.vb:lin e 8
    at System.AppDomai n.nExecuteAssem bly(Assembly assembly,
    String[] args)
    at System.AppDomai n.ExecuteAssemb ly(String assemblyFile,
    Evidence assemblySecurit y, String[] args)
    at Microsof

    details:

    '----------------------------------Client
    Imports System.Runtime. Remoting.Channe ls.Http
    Public Class Client
    Inherits System.Windows. Forms.Form

    Private theManager As InBetween.Manag er

    #Region " Windows Form Designer generated code "

    Public Sub New()
    MyBase.New()
    'This call is required by the Windows Form Designer.
    InitializeCompo nent()

    Dim chan As HttpChannel = New HttpChannel("0" )

    System.Runtime. Remoting.Channe ls.ChannelServi ces.RegisterCha nnel(chan)

    theManager =
    CType(Activator .GetObject(Type .GetType("InBet ween.Manager,In Between"),
    "http://localhost:7777/ChatApplication "), InBetween.Manag er)

    AddHandler Me.theManager.e vtReceiveText, AddressOf
    Me.HandleReceiv edMsg

    end sub
    #End Region

    Sub HandleReceivedM sg(ByVal username As String, ByVal text As
    String)
    Me.txtReceivedM sgs.AppendText( username & " : " & text &
    vbCrLf)
    End Sub

    end class

    '-------------------------------------Server
    Imports System.Runtime. Remoting.Channe ls
    Imports System.Runtime. Remoting.Channe ls.Http
    Imports System.Runtime. Remoting
    Imports System
    Imports InBetween

    public class Server

    Public Shared Sub Main()
    Dim server1 As Server
    server1 = New Server()
    End Sub

    Public Sub New()

    Dim chan As IChannel = New HttpChannel(777 7)

    ChannelServices .RegisterChanne l(chan)


    System.Runtime. Remoting.Remoti ngConfiguration .RegisterWellKn ownServiceType( _
    Type.GetType("I nBetween.Manage r, InBetween"), _
    "ChatApplicatio n", WellKnownObject Mode.Singleton)

    Dim Manager1 As New Manager()
    Console.WriteLi ne("The Manager object's ID2:" &
    Manager1.getHas h())
    System.Console. WriteLine("Hit ENTER to exit...")

    System.Console. ReadLine()

    End Sub

    end class

    '-------------------------------------Manager

    Imports System

    Public Delegate Sub ReceiveText(ByV al username As String, ByVal text
    As String)

    Public Class Manager
    Inherits MarshalByRefObj ect

    Public Event evtReceiveText As ReceiveText

    Public Overrides Function InitializeLifet imeService() As Object
    Return Nothing
    End Function

    Public Function SendText(ByVal username As String, ByVal text As
    String)
    RaiseEvent evtReceiveText( username, text)
    End Function

    End Class


    Howerver, I can call the methods of remoting object.

    Its very very urgent and I tried lot to resolve but i could not solve
    this problem.

    Please someone help me out and please suggest me if there are
    alternative ways to resolve this.

    Thanks.
    Shivkumar S.

  • Phill W.

    #2
    Re: vb.net error while registering evevents

    shivkumar2004@g mail.com wrote:
    I am getting the following error while registering the events.
    >
    error details: System.InvalidO perationExcepti on was unhandled
    Message="An error occurred creating the form. See
    Exception.Inner Exception for details. The error is: Type
    System.Delegate SerializationHo lder and the types derived from it (such
    as System.Delegate SerializationHo lder) are not permitted to be
    deserialized at this security level."
    Remoting supports two "security levels" which controls the kinds of
    objects that you can send across the "Great .Net Remoting Divide".
    It sounds to me like you're running at the "lower" level, which only
    supports basic, Framework-implemented types. You need to tell the
    remoting server to use the "higher" one, so that you can serialise your
    own Types as well.

    I don't know which property it would be, but in the remoting
    configuration file (which I use; I'm lazy) it would be specified as:


    <system.runtime .remoting>
    <application>
    <channels>
    <channel ref="tcp" port="12345">
    <serverProvider s>
    <formatter
    ref="binary"
    typeFilterLevel ="Full" <-- this one!
    />
    . . .

    HTH,
    Phill W.

    Comment

    Working...