Switching on FastSerialization

Posts   
 
    
Markiemac
User
Posts: 132
Joined: 25-Apr-2006
# Posted on: 09-Jun-2008 02:09:24   

Hi, (Using Adapter 2.5 & VB in a distributed WinForm app Hosted in IIS)

Since I started hosting my RemotingService in IIS, I get an "Exception has been thrown by the target of an invocation" error. This happens when I turn on FastSerialzation at the client end, as shown in this snip:

    Public Sub GetServiceReferences(ByVal ServerName As String)
        Dim channel As HttpClientChannel = New HttpClientChannel("HttpBinary", New BinaryClientFormatterSinkProvider())
        ChannelServices.RegisterChannel(channel, True)

        frmMain.factoryMainManager = DirectCast(Activator.GetObject(GetType(IMainManagerFactory), String.Format(ServerName & "EndPointMain.rem")), IMainManagerFactory)

        'Switch on FastSerialization
        SerializationHelper.Optimization = SerializationOptimization.Fast
    End Sub

Should I be switching on FastSerialization on the client side as well as the server side or is there something else that I should be doing?

Thanks for any help simple_smile

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 09-Jun-2008 03:46:21   

Please post some additional info:

  • RuntimeLibraries version (http://llblgen.com/TinyForum/Messages.aspx?ThreadID=7722).
  • Whole Exception message and stack trace (if it's too large, please attach it to your post).
  • What are you des/serializing? (EntityCollection, TypedList, etc.)
  • Does the error occur always or with some specific object?
David Elizondo | LLBLGen Support Team
simmotech
User
Posts: 1024
Joined: 01-Feb-2006
# Posted on: 09-Jun-2008 06:08:05   

Markiemac wrote:

Should I be switching on FastSerialization on the client side as well as the server side or is there something else that I should be doing?

Thanks for any help simple_smile

The setting has to be the same on both sides.

Cheers Simon

Markiemac
User
Posts: 132
Joined: 25-Apr-2006
# Posted on: 09-Jun-2008 13:48:23   

daelmo wrote:

Please post some additional info:

  • RuntimeLibraries version (http://llblgen.com/TinyForum/Messages.aspx?ThreadID=7722).
  • Whole Exception message and stack trace (if it's too large, please attach it to your post).
  • What are you des/serializing? (EntityCollection, TypedList, etc.)
  • Does the error occur always or with some specific object?

Runtime: 2.5.0.0 Exception & Stacktrace

System.InvalidOperationException was unhandled Message="An error occurred creating the form. See Exception.InnerException for details. The error is: Exception has been thrown by the target of an invocation." Source="ARTEMIS.WIN" StackTrace: at ARTEMIS.WIN.My.MyProject.MyForms.Create__Instance__[T](T Instance) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 190 at ARTEMIS.WIN.My.MyProject.MyForms.get_frmMain() at ARTEMIS.WIN.My.MyApplication.OnCreateMainForm() in C:\Projects\ARTEMIS\DevA\ARTEMIS\ARTEMIS.WIN\My Project\Application.Designer.vb:line 35 at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun() at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel() at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine) at ARTEMIS.WIN.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81 at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args) at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel) at System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly() at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData) at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()

Note The Exception occurs when I try to retrieve the OrganisationName from my SysParam table using the following statements:

        Dim sysParam As IMainManager = factoryMainManager.CreateMainManagerInstance
        OrganisationName = sysParam.GetSysParam.Name

The Exception is in CommonEntityBase.vb at MyBase.New(info, context)

        ''' <summary>Protected CTor for deserialization</summary>
        ''' <param name="info"></param>
        ''' <param name="context"></param>
        Protected Sub New(info As SerializationInfo, context As StreamingContext)
            MyBase.New(info, context)
            
            ' __LLBLGENPRO_USER_CODE_REGION_START DeserializationConstructor
            ' __LLBLGENPRO_USER_CODE_REGION_END
        End Sub

from Web.config

  <system.runtime.remoting>
    <application>
      <service>
        <wellknown mode="SingleCall" objectUri="EndPointMain.rem" type="ARTEMIS.RemotingService.MainManagerFactory, ARTEMIS.RemotingService"/>
        <wellknown mode="SingleCall" objectUri="EndPointLookup.rem" type="ARTEMIS.RemotingService.LookupTableManagerFactory, ARTEMIS.RemotingService"/>

      </service>
      <channels>
        <channel ref="http" useDefaultCredentials="true">
          <serverProviders>
            <provider ref="wsdl"/>
            <formatter ref="binary" typeFilterLevel="Full"/>
          </serverProviders>
        </channel>
      </channels>
    </application>
  </system.runtime.remoting>
  <system.web>

from app.config

  <system.runtime.remoting>
    <application>
      <channels>
        <channel ref="http" useDefaultCredentials="true">
          <clientProviders>
            <formatter ref="binary"/>
          </clientProviders>
        </channel>
      </channels>
  </application>
  </system.runtime.remoting>

Here is how I get the service references on the Client If I comment out SerializationHelper.Optimization = SerializationOptimization.Fast then there is no error

    Public Sub GetServiceReferences(ByVal ServerName As String)
        Dim channel As HttpClientChannel = New HttpClientChannel("HttpBinary", New BinaryClientFormatterSinkProvider())
        ChannelServices.RegisterChannel(channel, True)

        frmMain.factoryMainManager = DirectCast(Activator.GetObject(GetType(IMainManagerFactory), String.Format(ServerName & "EndPointMain.rem")), IMainManagerFactory)

        frmMain.factoryLookupTableManager = DirectCast(Activator.GetObject(GetType(ILookupTableManagerFactory), String.Format(ServerName & "EndPointLookup.rem")), ILookupTableManagerFactory)

        'Switch on FastSerialization
        SerializationHelper.Optimization = SerializationOptimization.Fast
    End Sub

I register the services like this

Namespace RemotingService
    Public Class RegisterObjects
        Public Shared Sub Main(ByVal args As String())
            'Register a channel and assign the service type to it
            Dim channel As New HttpChannel()
            ChannelServices.RegisterChannel(channel, True)

            Dim service1 As Type = Type.GetType("ARTEMIS.RemotingService.MainManagerFactory", True, False)
            RemotingConfiguration.RegisterWellKnownServiceType(service1, "EndPointMain.rem", WellKnownObjectMode.SingleCall)
            Dim service2 As Type = Type.GetType("ARTEMIS.RemotingService.LookupTableManagerFactory", True, False)
            RemotingConfiguration.RegisterWellKnownServiceType(service2, "EndPointLookup.rem", WellKnownObjectMode.SingleCall)
            ' switch on FastSerialization 
            SerializationHelper.Optimization = SerializationOptimization.Fast
        End Sub
    End Class
End Namespace

This all used to work when I hosted the RemotingService in a Console Application and having just written this I've just realised that the Application type of the RemotingService assembly is still set to Console Application confused

Is this the source of the problem, what should this be set to as its now being hosted in IIS, not a Console Application?

Sorry about the long post. Thanks

Walaa avatar
Walaa
Support Team
Posts: 14994
Joined: 21-Aug-2005
# Posted on: 10-Jun-2008 09:10:03   

Runtime: 2.5.0.0

That's not the runtime library version, please check the link posted by David.

Markiemac
User
Posts: 132
Joined: 25-Apr-2006
# Posted on: 10-Jun-2008 11:29:36   

Walaa wrote:

Runtime: 2.5.0.0

That's not the runtime library version, please check the link posted by David.

Whoops! Its 2.5.07.1214

As I mentioned above, my RemotingService was previously hosted in a Console Application using TCP, and this has worked ok. Having now switched to hosting it in IIS using Http, I can't get it working and have just realised that I need a different approach to registering the Services which were formerly done in the Console application.

As this may be the source of the above problem, what approach could I use to register my Services when hosting in IIS?

Sorry if this is basic stuff, but its been painful cry getting to this stage.

Thanks

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39872
Joined: 17-Aug-2003
# Posted on: 10-Jun-2008 20:39:16   

I think the general approach of registering remoting services in IIS would do. FastSerialization isn't affected by that.

Isn't it that using a HTTP channel instead of a TCP channel is enough to register in IIS? Anyway, if you set the fastserialization option on at the START of both sides (i.e. the service start and the client start) the option is on for all activity.

Frans Bouma | Lead developer LLBLGen Pro
Markiemac
User
Posts: 132
Joined: 25-Apr-2006
# Posted on: 13-Jun-2008 02:35:45   

I've just got back to this and can see that I was making Hosting in IIS more complex than needed. FastSerialization was not being switched on at the Server end, hence the error flushed