Please help me !
How can I get connection string in web.config file from server when Remote Object has been registed on IIS
The code details:
Remote Object:
Imports
System.Runtime.RemotingImports
System.Runtime.Remoting.Channels.HttpPublic
Class CustomerObject Inherits System.MarshalByRefObject Private m_strConnectionString As String Sub New()m_strConnectionString = System.Configuration.ConfigurationSettings.AppSettings("CNN_STR")
End Sub Public ReadOnly Property ConnectionString() As String Get Return m_strConnectionString End Get End PropertyEnd
ClassCilent.config:
<
xml version="1.0" encoding="utf-8" ><
configuration> <system.runtime.remoting> <application name="Client"> <client url="http://localhost/CustomerObject"> <wellknown type="RemoteObject.CustomerObject, CustomerObject" url="http://localhost/CustomerObject.soap"/> </client> <channels> <channel ref="http" /> </channels> </application> </system.runtime.remoting></
configuration>Web.config
<
xml version="1.0" encoding="utf-8" ><
configuration> <system.runtime.remoting> <application> <service> <wellknown mode="SingleCall" type="RemoteObject.CustomerObject, CustomerObject" objectUri="CustomerObject.soap" /> </service> </application> </system.runtime.remoting> <appSettings> <add key="CNN_STR" value="server=.;database=northwind;uid=sa;pwd=" /> </appSettings></
configuration>I create virtual directory server and create sub folder bin, the direcroty has included RemoteObject.dll file. Then I copy web.config to server folder.
Client:
Imports
System.Runtime.RemotingImports
System.Runtime.Remoting.Channels.HttpImports
RemoteObjectModule
Module1 Sub Main() TryConsole.WriteLine("Config Remote Object...")
'Load the Http Channel from the config fileRemotingConfiguration.Configure("Client.config")
Console.WriteLine("Create instance of remote object...")
'instantiate the remote object on the server '(this is really just a proxy object here) Dim objRemote As RemoteObject.CustomerObject = New RemoteObject.CustomerObject If (objRemote.ConnectionString = Nothing) ThenConsole.WriteLine("Connection string is nothing !")
ElseConsole.WriteLine(
String.Format("Connection string: {0}", objRemote.ConnectionString)) End IfConsole.WriteLine("Press any key to exit !")
Console.ReadLine()
Catch ex As ExceptionConsole.WriteLine(ex.Message)
Console.ReadLine()
End Try End SubEnd
ModuleWhen Client run, message Connection string is nothing ! has been writed on screen. It's mean Remote Object can get value of key CNN_STR in web.config file.
Please help me!!!!!!!!!!!!

How can I gen connection string in config file from server?
Steve Watts
craig1972
funti
Manh, can you try printing out the connection string on the service side to make sure your configuration call is completing successfully
Regards,
JJustice [MSFT]
RpM
Webman