resonatored


Hi all

i built a server, serverGUI & clientGUI, and remoting worked fine...

now i need to host the server as a service...

i built a test service that added some lines to the eventlog on a timer... that worked fine...

so i built a service that created the server object, instead of the ServerGUI,

the service loads up fine, then when you connect from the client, this exception is thrown...


************** Exception Text **************
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.FileNotFoundException: Could not load file or assembly 'ClientGUI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
File name: 'ClientGUI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.Load(String assemblyString)
at System.Reflection.MemberInfoSerializationHolder..ctor(SerializationInfo info, StreamingContext context)

=== Pre-bind state information ===
LOG: User = NT AUTHORITY\SYSTEM
LOG: DisplayName = ClientGUI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///C:/chat/MyService/bin/Release/
LOG: Initial PrivatePath = NULL
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/chat/MyService/bin/Release/ClientGUI.DLL.
LOG: Attempting download of new URL file:///C:/chat/MyService/bin/Release/ClientGUI/ClientGUI.DLL.
LOG: Attempting download of new URL file:///C:/chat/MyService/bin/Release/ClientGUI.EXE.
LOG: Attempting download of new URL file:///C:/chat/MyService/bin/Release/ClientGUI/ClientGUI.EXE.

--- End of inner exception stack trace ---

Server stack trace:
at System.RuntimeMethodHandle._SerializationInvoke(Object target, SignatureStruct& declaringTypeSig, SerializationInfo info, StreamingContext context)
at System.RuntimeMethodHandle.SerializationInvoke(Object target, SignatureStruct declaringTypeSig, SerializationInfo info, StreamingContext context)
at System.Reflection.RuntimeConstructorInfo.SerializationInvoke(Object target, SerializationInfo info, StreamingContext context)
at System.Runtime.Serialization.ObjectManager.CompleteISerializableObject(Object obj, SerializationInfo info, StreamingContext context)
at System.Runtime.Serialization.ObjectManager.FixupSpecialObject(ObjectHolder holder)
at System.Runtime.Serialization.ObjectManager.DoFixups()
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Remoting.Channels.CoreChannel.DeserializeBinaryRequestMessage(String objectUri, Stream inputStream, Boolean bStrictBinding, TypeFilterLevel securityLevel)
at System.Runtime.Remoting.Channels.BinaryServerFormatterSink.ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, IMessage& responseMsg, ITransportHeaders& responseHeaders, Stream& responseStream)

Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at SharedClasses.IServer.Connect(Parcel msgDel, Parcel usrDel, String userName)
at ClientGUI.ClientForm.btnConnect_Click(Object sender, EventArgs e) in C:\chat\ClientGUI\ClientForm.vb:line 41
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.832 (QFE.050727-8300)
CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
ClientGUI
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/chat/ClientGUI/bin/Release/ClientGUI.exe
----------------------------------------
Microsoft.VisualBasic
Assembly Version: 8.0.0.0
Win32 Version: 8.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualBasic/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
----------------------------------------
System
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.832 (QFE.050727-8300)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Windows.Forms
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.832 (QFE.050727-8300)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.832 (QFE.050727-8300)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Configuration
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.832 (QFE.050727-8300)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.832 (QFE.050727-8300)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
System.Runtime.Remoting
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.832 (QFE.050727-8300)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Runtime.Remoting/2.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll
----------------------------------------
SharedClasses
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/chat/ClientGUI/bin/Release/SharedClasses.DLL
----------------------------------------





******************************************************
My Code

Service Code
******************************************************


Imports System.Runtime.Remoting
Imports MyServer
Imports SharedClasses

Public Class MyService

Private proxy As Server

Protected Overrides Sub OnStart(ByVal args() As String)

RemotingConfiguration.Configure("C:\chat\MyService\bin\Release\ServerForm.config", False)

proxy = CType(Activator.GetObject(Type.GetType("SharedClasses.IServer, SharedClasses"), "tcp://localhost:8085/yakkityYak"), SharedClasses.IServer)

End Sub

Protected Overrides Sub OnStop()
' Add code here to perform any tear-down necessary to stop your service.
End Sub


End Class



*****************************************************
clientCode (only important bit really)
******************************************************

Dim chan As TcpChannel
Dim channelN As Integer = 0
chan = New TcpChannel(channelN)
RegisterChannel(chan, False)

'connect using
proxy = CType(Activator.GetObject(Type.GetType("SharedClasses.IServer, SharedClasses"), "tcp://localhost:8085/yakkityYak"), IServer)


*****************************************************

After two nights of frustration and reading, i still cant come to understand what is wrong...
It was working perfectly as an application, but has this problem when a service..

the application is very small and is basically a test for wether i can host the server from a service.

Can anyone point me in the right direction

Many thanks
red







Re: .NET Remoting and Runtime Serialization Service hosting a Remoting object, TargetInvocationException... FileNotFound... Could not load file or assembly

resonatored

Forgot to say the SharedClasses.IServer is an interface, that was used by the ServerGui, and Clients




Re: .NET Remoting and Runtime Serialization Service hosting a Remoting object, TargetInvocationException... FileNotFound... Could not load file or assembly

pankaj chaudhari

=== Pre-bind state information ===
LOG: User = NT AUTHORITY\SYSTEM
LOG: DisplayName = ClientGUI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///C:/chat/MyService/bin/Release/
LOG: Initial PrivatePath = NULL
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/chat/MyService/bin/Release/ClientGUI.DLL.
LOG: Attempting download of new URL file:///C:/chat/MyService/bin/Release/ClientGUI/ClientGUI.DLL.
LOG: Attempting download of new URL file:///C:/chat/MyService/bin/Release/ClientGUI.EXE.
LOG: Attempting download of new URL file:///C:/chat/MyService/bin/Release/ClientGUI/ClientGUI.EXE

If you look at the above exception log, it is clear that the assembly ClientGUI is needed and is being search at the base location of
C:/chat/MyService/bin/Release/

Are you missing that assembly from this location

- pankaj




Re: .NET Remoting and Runtime Serialization Service hosting a Remoting object, TargetInvocationException... FileNotFound... Could not load file or assembly

resonatored

thanks so much pankaj, i feel a bit stupid, didnt realise that the server must have a copy of the client too!!...

thanks heaps
red