Well, after a failed attempt (of I speak about here), I tried another approach.
So, I used an example application who works fine (it is your code, phucphlq) on local, with no remoting, configuration.
I tried to make it as client server one, with the server in a console app. This time, I use a config file for the server side, here it is.
<configuration>
<system.runtime.remoting>
<application>
<service>
<wellknown mode="SingleCall" objectUri="RemotingPortal.rem"
type="Csla.Server.Hosts.RemotingPortal, Csla"/>
</service>
<channels>
<channel ref="http" port="3187">
<serverProviders>
<provider ref="wsdl"/>
<formatter ref="soap" typeFilterLevel="Full"/>
<formatter ref="binary" typeFilterLevel="Full"/>
</serverProviders>
</channel>
</channels>
</application>
</system.runtime.remoting>
<connectionStrings>
<add name="DatabaseFile" connectionString="Db4oCSLA.yap" />
</connectionStrings>
</configuration>
And the server itself is very simple:
static void Main(string[] args)
{String filename = "..\\..\\App.config";
RemotingConfiguration.Configure(filename);
Console.WriteLine("ServerStartup.Main(): Server started");// the server will keep running until keypress.
Console.ReadLine();
}
Here is the client config file:
<configuration>
<appSettings>
<add key="CslaAuthentication" value="Windows" />
<add key="CslaDataPortalProxy"
value="Csla.DataPortalClient.RemotingProxy, Csla"/>
<add key="CslaDataPortalUrl"
value="http://localhost:3187/RemotingPortal.rem"/>
</appSettings>
<connectionStrings>
</connectionStrings>
</configuration>
When I use the client, I get the error “Principal must be of type BusinessPrincipal, not Nothing” at the line “return Csla.DataPortal.Create<EditableRootEmployee>();” from the public class EditableRootEmployee:Csla.BusinessBase<EditableRootEmployee>.
Here is the code:
public static EditableRootEmployee New()
{
return Csla.DataPortal.Create<EditableRootEmployee>();
}
protected override void DataPortal_Create()
{
MarkOld();
}
And the complete exception
System.Security.SecurityException was unhandled
Message="Principal must be of type BusinessPrincipal, not Nothing"
Source="Csla"
StackTrace:
Server stack trace:
à Csla.Server.DataPortal.SetContext(DataPortalContext context)
à Csla.Server.DataPortal.Create(Type objectType, Object criteria, DataPortalContext context)
à Csla.Server.Hosts.RemotingPortal.Create(Type objectType, Object criteria, DataPortalContext context)
à System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
à System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(RuntimeMethodHandle md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
à System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)
Exception rethrown at [0]:
à System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
à System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
à Csla.Server.IDataPortalServer.Create(Type objectType, Object criteria, DataPortalContext context)
à Csla.DataPortalClient.RemotingProxy.Create(Type objectType, Object criteria, DataPortalContext context)
à Csla.DataPortal.Create(Type objectType, Object criteria)
à Csla.DataPortal.Create[T]()
à Business.EditableRootEmployee.New() dans C:\Documents and Settings\PETITDM\Mes documents\Visual Studio 2005\Projects\Tests\db4oprogs\db4oCSLA\Test CS2\Business\EditableRootEmployee.cs:ligne 57
à Db4oAndCSLA.MainForm..ctor() dans C:\Documents and Settings\PETITDM\Mes documents\Visual Studio 2005\Projects\Tests\db4oprogs\db4oCSLA\Test CS2\Db4oAndCSLA\MainForm.cs:ligne 17
à Db4oAndCSLA.Program.Main() dans C:\Documents and Settings\PETITDM\Mes documents\Visual Studio 2005\Projects\Tests\db4oprogs\db4oCSLA\Test CS2\Db4oAndCSLA\Program.cs:ligne 17
à System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
à System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
à Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
à System.Threading.ThreadHelper.ThreadStart_Context(Object state)
à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
à System.Threading.ThreadHelper.ThreadStart()
Again, any help would be welcome
Thanks
Richard
Edit: That's ok, I found the solution here , I added
<appSettings>
<add key="CslaAuthentication" value="Windows" />
</appSettings>
in the config file of the server.
Copyright (c) Marimer LLC