My app.config:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="DalManagerType" value="MyDb.DalEf.DalManager,MyDb.DalEf"/>
<add key="CslaDataPortalProxy" value="Csla.DataPortalClient.WcfProxy, Csla"/>
<add key="CslaDataPortalUrl" value="http://localhost:52348/WcfPortal.svc"/>
<!--<add key="CslaDataPortalProxy" value="Local" />-->
<!--<add key="CslaAuthentication" value="Windows"/>-->
</appSettings>
<connectionStrings>
<add name="CharisCTKEntities" connectionString="metadata=res://*/MyDb.csdl|res://*/MyDb.ssdl|res://*/MyDb.msl;provider=System.Data.SqlClient;provider connection string="Data Source=MyComputer;Initial Catalog=MyDb;Integrated Security=True;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient"/>
</connectionStrings>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
Test code excerpt:
{
var principal = new System.Security.Principal.GenericPrincipal(
new System.Security.Principal.GenericIdentity("Test"),
new string[] { "ContractManager" });
Csla.ApplicationContext.User = principal;
CC.CharisCTK.Library.Security.CTPrincipal.Login("john", "john");
var obj = ContractEdit.NewContract();
obj.CompanyName = "My Company";
obj.StartDate = Convert.ToDateTime("6/1/2011");
obj = obj.Save(); //error happens here
ContractEdit.DeleteContract(obj.Id);
}
Any help on how to troubleshoot this problem would be greatly appreciated.
Thank you
You must use a serializable principal and we recommend that you use CslaPrincipal/CslaIdentity rather than GenericPrincipal/GenericIdentity.
When you use remote proxy the user principal is also serialized and sent to the server.
Hi Jonny,
Thank you very much for your reply. I'll make the changes you recommended and see how it goes.
Helio
Hi Jonny,
I changed my code to use CslaPrincipal/CslaIndenty but I still cannot get the remote proxy to work.
I have a bit more info:
(1) The code actually inserts the record to the database but fails to deserialize the object to the client.
(2) This is the information from the WCF trace:
><Message>The specified domain either does not exist or could not be contacted</Message><StackTrace> at System.ServiceModel.UpnEndpointIdentity.GetUpnFromDownlevelName(String downlevelName)
The service '/WcfPortal.svc' cannot be activated due to an exception during compilation. The exception message is: The configuration section cannot contain a CDATA or text element. (D:\Development\MyDb.Wcf\web.config line 41). ---&gt; System.Configuration.ConfigurationErrorsException: The configuration section cannot contain a CDATA or text element. (D:\Development\MyDb.Wcf\web.config line 41)
I've already checked the Web.config file and removed all comments that could possibly cause CDATA errors but it still doesn't work. Any help to direct me to the solution would be great for I am very keen to have the remote proxy approach working.
(3) Here's a copy of the D:\Development\MyDb.Wcf\web.config :
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="DalManagerType" value="MyDb.DalEf.DalManager,MyDb.DalEf"/>
<add key="CslaDataPortalUrl" value="http://localhost:52348/WcfPortal.svc"/>
</appSettings>
<connectionStrings>
<add name="MyDbEntities" connectionString="metadata=res://*/MyDb.csdl|res://*/MyDb.ssdl|res://*/MyDb.msl;provider=System.Data.SqlClient;provider connection string="Data Source=Machine01;Initial Catalog=MyDb;Integrated Security=True;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient"/>
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<httpRuntime maxRequestLength="2147483647"/>
</system.web>
<system.diagnostics>
<sources>
<source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
<listeners>
<add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="c:\temp\WcfTrace.xml" />
</listeners>
</source>
</sources>
<trace autoflush="true" />
</system.diagnostics>
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<services>
<service name="Csla.Server.Hosts.WcfPortal"
behaviorConfiguration="returnFaults">
<endpoint binding="wsHttpBinding" bindingConfiguration="wsHttpBinding_IWcfPortal"
contract="Csla.Server.Hosts.IWcfPortal"/>
</service>
<service name="Csla.Server.Hosts.Silverlight.WcfPortal"
behaviorConfiguration="returnFaults" >
<endpoint binding="basicHttpBinding" bindingConfiguration="basicHttpBinding_IWcfPortal"
contract="Csla.Server.Hosts.Silverlight.IWcfPortal"/>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBinding_IWcfPortal"
maxReceivedMessageSize="2147483647"
maxBufferPoolSize="2147483647"
maxBufferSize="2147483647" receiveTimeout="00:10:00" sendTimeout="00:10:00">
<readerQuotas maxBytesPerRead="2147483647"
maxArrayLength="2147483647"
maxStringContentLength="2147483647"
maxNameTableCharCount="2147483647"
maxDepth="2147483647"/>
</binding>
</basicHttpBinding>
<wsHttpBinding>
<binding name="wsHttpBinding_IWcfPortal"
maxReceivedMessageSize="2147483647" receiveTimeout="00:10:00" sendTimeout="00:10:00">
<readerQuotas maxBytesPerRead="2147483647"
maxArrayLength="2147483647"
maxStringContentLength="2147483647"
maxNameTableCharCount="2147483647"
maxDepth="2147483647"/>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="returnFaults">
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
Are you following the setup for server and client config as described in Using CSLA 4: Data Portal Configuration?
Are you absolutely sure that you are using the .NET Csla.dll on the server, and the appropiately targeted Csla.dll for your client (.NET/SL/WP)?
The problem was with the client configuration. All's well now.
Thank you for your help.
Copyright (c) Marimer LLC