I will be starting a new project with VS 2005 later this week and I'm planning on using version 2.0.2 of CSLA as the framework for it. I've been playing around with PTracker to check out the changes in how it operates with CSLA compared to the two in version 1.5. Everything worked quite well when running it with the local dataportal, but knowing the project I'll be working on requires a remote portal, I uncommented the appropriate sections of the app.config file for PTWin. When I tried running it with the remote portal, I encountered an unhandled serialization exception. A portion of the details are as follows:
System.Runtime.Serialization.SerializationException was unhandled
Message="The input stream is not a valid binary format. The starting contents (in bytes) are: 3C-68-74-6D-6C-3E-0D-0A-20-20-20-20-3C-68-65-61-64 ..."
Source="mscorlib"
StackTrace:
Server stack trace:
at System.Runtime.Serialization.Formatters.Binary.SerializationHeaderRecord.Read(__BinaryParser input)
at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadSerializationHeaderRecord()
at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run()
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.DeserializeBinaryResponseMessage(Stream inputStream, IMethodCallMessage reqMsg, Boolean bStrictBinding)
at System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessage(IMessage msg)
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 Csla.Server.IDataPortalServer.Fetch(Type objectType, Object criteria, DataPortalContext context)
at Csla.DataPortalClient.RemotingProxy.Fetch(Type objectType, Object criteria, DataPortalContext context) in C:\Visual Studio 2005 Projects\cslacs20-2.0.2\csla20cs\csla20cs\Csla\DataPortal\Client\RemotingProxy.cs:line 111
at Csla.DataPortal.Fetch(Type objectType, Object criteria) in C:\Visual Studio 2005 Projects\cslacs20-2.0.2\csla20cs\csla20cs\Csla\DataPortal\Client\DataPortal.cs:line 184
at Csla.DataPortal.Fetch[T](Object criteria) in C:\Visual Studio 2005 Projects\cslacs20-2.0.2\csla20cs\csla20cs\Csla\DataPortal\Client\DataPortal.cs:line 138
at ProjectTracker.Library.Security.PTIdentity.GetIdentity(String username, String password) in C:\Visual Studio 2005 Projects\cslacs20-2.0.2\csla20cs\ProjectTracker20cs\ProjectTracker.Library\Security\PTIdentity.cs:line 57
at ProjectTracker.Library.Security.PTPrincipal.Login(String username, String password) in C:\Visual Studio 2005 Projects\cslacs20-2.0.2\csla20cs\ProjectTracker20cs\ProjectTracker.Library\Security\PTPrincipal.cs:line 15
at PTWin.LoginForm.OK_Click(Object sender, EventArgs e) in C:\Visual Studio 2005 Projects\cslacs20-2.0.2\csla20cs\ProjectTracker20cs\PTWin\LoginForm.cs:line 23
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.PerformClick()
at System.Windows.Forms.Form.ProcessDialogKey(Keys keyData)
at System.Windows.Forms.TextBoxBase.ProcessDialogKey(Keys keyData)
at System.Windows.Forms.Control.PreProcessMessage(Message& msg)
at System.Windows.Forms.Control.PreProcessControlMessageInternal(Control target, Message& msg)
at System.Windows.Forms.Application.ThreadContext.PreTranslateMessage(MSG& msg)
at System.Windows.Forms.Application.ThreadContext.System.Windows.Forms.UnsafeNativeMethods.IMsoComponent.FPreTranslateMessage(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
at PTWin.MainForm.DoLogin() in C:\Visual Studio 2005 Projects\cslacs20-2.0.2\csla20cs\ProjectTracker20cs\PTWin\MainForm.cs:line 321
at PTWin.MainForm.MainForm_Load(Object sender, EventArgs e) in C:\Visual Studio 2005 Projects\cslacs20-2.0.2\csla20cs\ProjectTracker20cs\PTWin\MainForm.cs:line 33
I've used the code "as-is", making modifications only to PTWin's app.config file, as mentioned earlier, and modifying RemotingHost's web.config file to point to the database locations for security.mdf and ptracker.mdf. I also have an IIS virtual directory pointing to the location of the RemotingHost directory. Why am I getting this error and what can I do to resolve it?
I don't know if it will help any, but I've copied the top three items on the Call Stack and they are as follows:
Csla.dll!Csla.DataPortalClient.RemotingProxy.Fetch(System.Type objectType = {Name = "PTIdentity" FullName = "ProjectTracker.Library.Security.PTIdentity"}, object criteria = {ProjectTracker.Library.Security.PTIdentity.Criteria}, Csla.Server.DataPortalContext context = {Csla.Server.DataPortalContext}) Line 111
Csla.dll!Csla.DataPortal.Fetch(System.Type objectType = {Name = "PTIdentity" FullName = "ProjectTracker.Library.Security.PTIdentity"}, object criteria = {ProjectTracker.Library.Security.PTIdentity.Criteria}) Line 184 + 0x12 bytes
Csla.dll!Csla.DataPortal.Fetch<ProjectTracker.Library.Security.PTIdentity>(object criteria = {ProjectTracker.Library.Security.PTIdentity.Criteria}) Line 138 + 0x34 bytes
Additionally, when I try to navigate to http://localhost/remotinghost/remotingportal.rem?wsdl as was done with CSLA 1.5 to verify the remote portal, I got back the following:
System.BadImageFormatException: The format of the file 'Csla' is invalid.
File name: "Csla"
at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Boolean isStringized, Evidence assemblySecurity, Boolean throwOnFileNotFound, Assembly locationHint, StackCrawlMark& stackMark)
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Boolean stringized, Evidence assemblySecurity, StackCrawlMark& stackMark)
at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark)
at System.Reflection.Assembly.Load(String assemblyString)
at System.Runtime.Remoting.RemotingConfigInfo.LoadType(String typeName, String assemblyName)
at System.Runtime.Remoting.RemotingConfigInfo.GetServerTypeForUri(String URI)
at System.Runtime.Remoting.RemotingConfigHandler.GetServerTypeForUri(String URI)
at System.Runtime.Remoting.RemotingServices.GetServerTypeForUri(String URI)
at System.Runtime.Remoting.Channels.Http.HttpRemotingHandler.CanServiceRequest(HttpContext context)
at System.Runtime.Remoting.Channels.Http.HttpRemotingHandler.InternalProcessRequest(HttpContext context)
=== Pre-bind state information ===
LOG: DisplayName = Csla
(Partial)
LOG: Appbase = file:///C:/Visual Studio 2005 Projects/cslacs20-2.0.2/csla20cs/ProjectTracker20cs/www/RemotingHost
LOG: Initial PrivatePath = bin
Calling assembly : (Unknown).
===
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Post-policy reference: Csla
LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET Files/remotinghost/aacc57bc/441a8e6b/Csla.DLL.
LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET Files/remotinghost/aacc57bc/441a8e6b/Csla/Csla.DLL.
LOG: Attempting download of new URL file:///C:/Visual Studio 2005 Projects/cslacs20-2.0.2/csla20cs/ProjectTracker20cs/www/RemotingHost/bin/Csla.DLL.
I find it rather odd that it attempted to download new URLs from the .NET Framework version 1.1. I do still have VS 2003 loaded as I occasionally have to maintain code written to take advantage of CSLA 1.5.
It looks as if you're having the exact same problem I had with the only difference being that you're encountering it while attempting to use remoting with your own application rather than with PTracker. First, you'll need to determine what port ASP.NET is using to host your RemotingPortal; in my case, it was 1732. Using that port number, modify the line beginning with <add key = "CslaDataPortalUrl" in the app.config file for your app such that the value portion of the key-value pair includes the port number. In my case, a change from "localhost/MyRemotingHost/RemotingPortal.rem" to "localhost:1732/MyRemotingHost/RemotingPortal.rem" was all it took to get it working.
HTH,
Allen B. Anderson
Thanks albruan,
I have no problem running PTracker and using the same configuraton step I can't make my application to work. However I am not using Csla with SQL Server but MySql using MySql.Data.MySqlClient 1.0.7, MySql 5.0.22 I am not sure that is the root of the problem or not?
Many thanks,
Kids
Kids,
Wow! I honestly don't know what to suggest doing, but I very seriously doubt it's because you're using MySQL. It still looks like it's the same problem that I had. As stated in my original post on this topic, and cleaned up some, I got the following response:
The input stream is not a valid binary format. The starting contents (in bytes) are: 3C-68-74-6D-6C-3E-0D-0A-20-20-20-20-3C-68-65-61-64 ...
Server stack trace:
at System.Runtime.Serialization.Formatters.Binary.SerializationHeaderRecord.Read(__BinaryParser input)
at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadSerializationHeaderRecord()
at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run()
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.DeserializeBinaryResponseMessage(Stream inputStream, IMethodCallMessage reqMsg, Boolean bStrictBinding)
at System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessage(IMessage msg)
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 Csla.Server.IDataPortalServer.Fetch(Type objectType, Object criteria, DataPortalContext context)
at Csla.DataPortalClient.RemotingProxy.Fetch(Type objectType, Object criteria, DataPortalContext context)
at Csla.DataPortal.Fetch(Type objectType, Object criteria)
at Csla.DataPortal.Fetch[T](Object criteria)
at ProjectTracker.Library.Security.PTIdentity.GetIdentity(String username, String password) in C:\Visual Studio 2005 Projects\cslacs20-2.0.2\csla20cs\ProjectTracker20cs\ProjectTracker.Library\Security\PTIdentity.cs:line 57
at ProjectTracker.Library.Security.PTPrincipal.Login(String username, String password) in C:\Visual Studio 2005 Projects\cslacs20-2.0.2\csla20cs\ProjectTracker20cs\ProjectTracker.Library\Security\PTPrincipal.cs:line 15
at PTWin.LoginForm.OK_Click(Object sender, EventArgs e) in C:\Visual Studio 2005 Projects\cslacs20-2.0.2\csla20cs\ProjectTracker20cs\PTWin\LoginForm.cs:line 23
If you compare the above with the exception message you are getting back, the two are identical in all respects except for the starting contents of the input string and the last three lines of the message due to my using PTracker and the Click event on a login form whereas you are using RSMS and the Load event of your main form. The contents themselves shouldn't make any difference as I'd gotten a different input string back before rebooting my machine. Hmmm, there is one more difference that I just noticed and that is that GetIdentity(String username, String password) in my case occurs on line 57 and that GetIdentity(String username, String PIN) in your case is on line 47. I doubt that'd make any difference as I'm sure it's only because I'm authenticating the user against the database while it appears you are authenticating them based on their network login.
Anyway, all this isn't to say you aren't having this problem because of your using MySQL and the MySQL Client as the back-end; I honestly don't know since I've always used SQL Server with the CSLA framework on my projects. Having said that, I am considering using MySQL on a project I've just started due to it's ability to handle partitioned tables like SQL Server Enterprise Edition but at a considerably lower cost than the roughly $24,000-per-processor licensing fee MS charges for MSEE. Anyway, if you have the source code for the MySQL Client, set a breakpoint on the first line that should execute in it and then single-step through the rest of the code before control is returned to the GetIdentity routine. Maybe something will turn up there; odds are you won't even hit the MySQL Client before the exception occurs.
Other than that, I don't know what to suggest. Maybe you should start a new thread with a topic heading something like "Remoting problem with MySQL" and describe the problem there. There are bound to be several others on here that are using MySQL as the back-end for their applications and maybe they'll be able to help. I wish you luck!
Allen B. Anderson
Kids, maybe you should start from scratch to make sure you can configure remoting correctly. Try this...
Getting remoting to work the first time involves a few steps.
1) Create a web project and add the Csla.dll as a reference, and all of your BO dlls that you have created. Call you web project MyRemotingTest
2) Add a web.config file into this web project and configure it properly... add the following in the <system.runtime.remoting> section.
<system.runtime.remoting>
<application>
<service>
<wellknown mode="SingleCall" objectUri="RemotingPortal.rem " type="Csla.Server.Hosts.RemotingPortal, Csla"/>
</service>
<channels>
<channel ref="http">
<serverProviders>
<provider ref="wsdl"/>
<formatter ref="soap" typeFilterLevel="Full"/>
<formatter ref="binary" typeFilterLevel="Full"/>
</serverProviders>
</channel>
</channels>
</application>
</system.runtime.remoting>
3) Go into IIS and create a virtual directory and call it MyRemotingTest and have it pointed to you web project . If you have both the .Net framework 1.1 and 2.0 install you'll have to set your virtual directory to use 2.0 - it uses 1.1 by default.
4) Test the remoting works by typing the following in your browser.
http://localhost/MyRemoringTest/RemotingPortal.rem?wsdl
If remoting works, you should get something similar to this...
5) Now that you have confirmed that remoting works, create client app and add the Csla.dll as a reference, and all of your BO dlls that you have created.
6) Add an app.config file to you client app and add to following in the <appSettings> section.
<appSettings>
<add key="CslaAuthentication" value="Csla" />
<add key="CslaDataPortalProxy" value="Csla.DataPortalClient.RemotingProxy, Csla"/>
<add key="CslaDataPortalUrl" value="http://localhost/MyRemoringTest/RemotingPortal .rem"/>
</appSettings>
7) VoilĂ , remoting should work.
Hope this helps.
Copyright (c) Marimer LLC