upgrading from Csla 3.8.2 to 4.0 using Silverlight 4 and VB

upgrading from Csla 3.8.2 to 4.0 using Silverlight 4 and VB

Old forum URL: forums.lhotka.net/forums/t/9394.aspx


germie posted on Tuesday, August 17, 2010

im watching the CSLA 4 MVVM video series. i need to build a silverlight app similar to the one shown in the CSLA .NET for Silverlight video series in VB using wcf to access data on our server. trying to use the .Client, .Server and DataAccess project approach but not too sure what Csla Dlls to use in each project. what i did so far is put the Client Dlls in the DataAccess and .Server projects. the Silverlight Dlls in the .Client and Silverlight projects. and the Server Dlls in the .Web project. all this is being done in VS 2010, Silverlight 4 and Csla 4.

when i run the app if fails at the EmployeeEdit.Client.vb class at db.BeginCreate()

Public Shared Sub GetEmployeeEdit(ByVal callback As EventHandler(Of DataPortalResult(Of EmployeeEdit)))
   Dim db = New DataPortal(Of EmployeeEdit)
   AddHandler db.CreateCompleted, callback
   db.BeginCreate()
End Sub

i get this error

System.InvalidOperationException was unhandled by user code
  Message=Could not find default endpoint element that references contract 'WcfPortal.IWcfPortal' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.
  StackTrace:
       at System.ServiceModel.Description.ConfigLoader.LoadChannelBehaviors(ServiceEndpoint serviceEndpoint, String configurationName)
       at System.ServiceModel.ChannelFactory.ApplyConfiguration(String configurationName)
       at System.ServiceModel.ChannelFactory.InitializeEndpoint(String configurationName, EndpointAddress address)
       at System.ServiceModel.ChannelFactory`1..ctor(String endpointConfigurationName, EndpointAddress remoteAddress)
       at System.ServiceModel.EndpointTrait`1.CreateSimplexFactory()
       at System.ServiceModel.EndpointTrait`1.CreateChannelFactory()
       at System.ServiceModel.ClientBase`1.CreateChannelFactoryRef(EndpointTrait`1 endpointTrait)
       at System.ServiceModel.ClientBase`1.InitializeChannelFactoryRef()
       at System.ServiceModel.ClientBase`1..ctor()
       at Csla.WcfPortal.WcfPortalClient..ctor()
       at Csla.DataPortalClient.WcfProxy`1.GetProxy()
       at Csla.DataPortalClient.WcfProxy`1.BeginCreate()
       at Csla.DataPortal`1.BeginCreate()
       at Demo.EmployeeEdit.GetEmployeeEdit(EventHandler`1 callback)
  InnerException:

after getting this i changed the endpoint contract in the ServiceReferences.ClientConfig from contract ="Csla.WcfPortal.IWcfPortal" to contract ="WcfPortal.IWcfPortal"

when i run it like this the Visual Studio Just-In-Time Debugger comes up stating "An unhandled exception ('Unhandled Error in Silverlight Application Code:4004 Category: ManagedRuntimeError Message: System.Reflection.targetInvocationException: An exception occurred during the operation, making the result invalid. Check". i cant use any of the Possible Debuggers. it just states "Unable to attach to the crashing process. A debugger is already attached. i do get this error in IE.

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.2; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E)
Timestamp: Tue, 17 Aug 2010 21:01:05 UTC

Message: Unhandled Error in Silverlight Application
Code: 4004   
Category: ManagedRuntimeError      
Message: System.Reflection.TargetInvocationException: An exception occurred during the operation, making the result invalid.  Check InnerException for exception details. ---> System.ServiceModel.CommunicationException: An error occurred while trying to make a request to URI 'http://localhost:5678/DemoService.svc'. This could be due to attempting to access a service in a cross-domain way without a proper cross-domain policy in place, or a policy that is unsuitable for SOAP services. You may need to contact the owner of the service to publish a cross-domain policy file and to ensure it allows SOAP-related HTTP headers to be sent. This error may also be caused by using internal types in the web service proxy without using the InternalsVisibleToAttribute attribute. Please see the inner exception for more details. ---> System.Security.SecurityException ---> System.Security.SecurityException: Security error.
   at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
   at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClass5.<EndGetResponse>b__4(Object sendState)
   at System.Net.Browser.AsyncHelper.<>c__DisplayClass2.<BeginOnUI>b__0(Object sendState)
   --- End of inner exception stack trace ---
   at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
   at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
   at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result)
   --- End of inner exception stack trace ---
   at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)
   at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
   at System.ServiceModel.ClientBase`1.ChannelBase`1.EndInvoke(String methodName, Object[] args, IAsyncResult result)
   at Csla.WcfPortal.WcfPortalClient.WcfPortalClientChannel.EndCreate(IAsyncResult result)
   at Csla.WcfPortal.WcfPortalClient.Csla.WcfPortal.IWcfPortal.EndCreate(IAsyncResult result)
   at Csla.WcfPortal.WcfPortalClient.OnEndCreate(IAsyncResult result)
   at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result)
   --- End of inner exception stack trace ---
   at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary()
   at Csla.WcfPortal.CreateCompletedEventArgs.get_Result()
   at Csla.DataPortalClient.WcfProxy`1.proxy_CreateCompleted(Object sender, CreateCompletedEventArgs e)
   at Csla.WcfPortal.WcfPortalClient.OnCreateCompleted(Object state)    

Line: 56
Char: 13
Code: 0
URI: http://localhost:1032/SlDemo_VBTestPage.aspx

dont know what to do at this point. are there any examples out there? please help!
thank you
germie

RockfordLhotka replied on Wednesday, August 18, 2010

Microsoft changed something in the way the client config file works. Generally, you just need to remove the "Csla." from the type name of the contract and it should work. Why? Who knows - something quirky between WCF in SL3 and SL4...

germie replied on Wednesday, August 18, 2010

thnx for the reply rocky,

i did try that, then got a different error. did i put the dlls in the right place? are there any code examples?

 

"

after getting this i changed the endpoint contract in the ServiceReferences.ClientConfig from contract ="Csla.WcfPortal.IWcfPortal" to contract ="WcfPortal.IWcfPortal"

when i run it like this the Visual Studio Just-In-Time Debugger comes up stating "An unhandled exception ('Unhandled Error in Silverlight Application Code:4004 Category: ManagedRuntimeError Message: System.Reflection.targetInvocationException: An exception occurred during the operation, making the result invalid. Check". i cant use any of the Possible Debuggers. it just states "Unable to attach to the crashing process. A debugger is already attached. i do get this error in IE.

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.2; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E)
Timestamp: Tue, 17 Aug 2010 21:01:05 UTC

Message: Unhandled Error in Silverlight Application
Code: 4004   
Category: ManagedRuntimeError      
Message: System.Reflection.TargetInvocationException: An exception occurred during the operation, making the result invalid.  Check InnerException for exception details. ---> System.ServiceModel.CommunicationException: An error occurred while trying to make a request to URI 'http://localhost:5678/DemoService.svc'. This could be due to attempting to access a service in a cross-domain way without a proper cross-domain policy in place, or a policy that is unsuitable for SOAP services. You may need to contact the owner of the service to publish a cross-domain policy file and to ensure it allows SOAP-related HTTP headers to be sent. This error may also be caused by using internal types in the web service proxy without using the InternalsVisibleToAttribute attribute. Please see the inner exception for more details. ---> System.Security.SecurityException ---> System.Security.SecurityException: Security error.
   at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
   at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClass5.<EndGetResponse>b__4(Object sendState)
   at System.Net.Browser.AsyncHelper.<>c__DisplayClass2.<BeginOnUI>b__0(Object sendState)
   --- End of inner exception stack trace ---
   at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
   at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
   at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result)
   --- End of inner exception stack trace ---
   at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)
   at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
   at System.ServiceModel.ClientBase`1.ChannelBase`1.EndInvoke(String methodName, Object[] args, IAsyncResult result)
   at Csla.WcfPortal.WcfPortalClient.WcfPortalClientChannel.EndCreate(IAsyncResult result)
   at Csla.WcfPortal.WcfPortalClient.Csla.WcfPortal.IWcfPortal.EndCreate(IAsyncResult result)
   at Csla.WcfPortal.WcfPortalClient.OnEndCreate(IAsyncResult result)
   at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result)
   --- End of inner exception stack trace ---
   at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary()
   at Csla.WcfPortal.CreateCompletedEventArgs.get_Result()
   at Csla.DataPortalClient.WcfProxy`1.proxy_CreateCompleted(Object sender, CreateCompletedEventArgs e)
   at Csla.WcfPortal.WcfPortalClient.OnCreateCompleted(Object state)    

Line: 56
Char: 13
Code: 0
URI: http://localhost:1032/SlDemo_VBTestPage.aspx

dont know what to do at this point. are there any examples out there? please help!
thank you
germie

                    "

germie replied on Tuesday, August 24, 2010

looks like im on my own figuring this one out. a good example ive found is here "http://www.lhotka.net/cslanet/download.aspx". just download the Samples for CSLA Version 4.0.0. the SimpleApp.sln gives you the .Server .Client examples similar to the ones given in the "CSLA .NET for Silverlight video series". through trial and error ive discovered that the Silverlight Dlls go in to the .Client and the Silverlight projects and the Client Dlls go in the .Server and .Web projects. the naming is a little confusing cause you would think that client would go into client and sever into server. now its just a matter of figuring out how to merge this example with the mvvm example in the "CSLA 4 MVVM video series" and ive got what i need. :)

germie

RockfordLhotka replied on Tuesday, August 24, 2010

I've mentioned this in a couple threads now, but here's the layout of the CSLA 4 binaries:

It doesn't matter if you use the Csla.dll from Client or Server - they are the same. All the other assemblies are different as described above.

germie replied on Wednesday, August 25, 2010

thank you for your explanation.

Copyright (c) Marimer LLC