music7611 Posted March 22, 2004 Posted March 22, 2004 (edited) I have this program that sends an object to a differant program on a differant computer. It uses BinaryFormatter. That program has an exact copy of that class. Is there any way to do this without using DLLs or anything? Edited March 22, 2004 by music7611 Quote
spatuel Posted March 23, 2004 Posted March 23, 2004 Can you send me more details? I can manage to produce a binary serialization of my class , storing it on a folder and then loading it from other application instance. I am not using any DLL, you can serialize using a normal APP or a WEB app as well. Indeed I have four engines running as a service that serialize the data and can share information. Salvador Quote
music7611 Posted March 27, 2004 Author Posted March 27, 2004 OK. So I have 2 Entirely Differant Applications. They each have the same class inside of them. They are each on 2 differant computers. The sender program is called ATM. Whenever I send the data, I get an error that says this... System.IO.FileNotFoundException: File or assembly name ATM, or one of its dependencies, was not found. File name: "ATM" 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.Serialization.Formatters.Binary.BinaryAssemblyInfo.GetAssembly() at System.Runtime.Serialization.Formatters.Binary.ObjectReader.GetType(BinaryAssemblyInfo assemblyInfo, String name) at System.Runtime.Serialization.Formatters.Binary.ObjectMap..ctor(String objectName, String[] memberNames, BinaryTypeEnum[] binaryTypeEnumA, Object[] typeInformationA, Int32[] memberAssemIds, ObjectReader objectReader, Int32 objectId, BinaryAssemblyInfo assemblyInfo, SizedArray assemIdToAssemblyTable) at System.Runtime.Serialization.Formatters.Binary.ObjectMap.Create(String name, String[] memberNames, BinaryTypeEnum[] binaryTypeEnumA, Object[] typeInformationA, Int32[] memberAssemIds, ObjectReader objectReader, Int32 objectId, BinaryAssemblyInfo assemblyInfo, SizedArray assemIdToAssemblyTable) at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryObjectWithMapTyped record) at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryHeaderEnum binaryHeaderEnum) at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run() at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, IMethodCallMessage methodCallMessage) at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, IMethodCallMessage methodCallMessage) at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream) at ChatClient.Client.RunClient() in c:\documents and settings\leeran\desktop\desktop stuff\ship\tcp connection\fig22_2\chatclient\client.cs:line 177 Fusion log follows: === Pre-bind state information === LOG: DisplayName = ATM, Version=1.0.1546.33420, Culture=neutral, PublicKeyToken=null (Fully-specified) LOG: Appbase = C:\Documents and Settings\Leeran\Desktop\Desktop Stuff\ship\TCP Connection\Fig22_2\ChatClient\bin\Debug\ LOG: Initial PrivatePath = NULL 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: ATM, Version=1.0.1546.33420, Culture=neutral, PublicKeyToken=null LOG: Attempting download of new URL file:///C:/Documents and Settings/Leeran/Desktop/Desktop Stuff/ship/TCP Connection/Fig22_2/ChatClient/bin/Debug/ATM.DLL. LOG: Attempting download of new URL file:///C:/Documents and Settings/Leeran/Desktop/Desktop Stuff/ship/TCP Connection/Fig22_2/ChatClient/bin/Debug/ATM/ATM.DLL. LOG: Attempting download of new URL file:///C:/Documents and Settings/Leeran/Desktop/Desktop Stuff/ship/TCP Connection/Fig22_2/ChatClient/bin/Debug/ATM.EXE. LOG: Attempting download of new URL file:///C:/Documents and Settings/Leeran/Desktop/Desktop Stuff/ship/TCP Connection/Fig22_2/ChatClient/bin/Debug/ATM/ATM.EXE. Can you help me? Quote
jamiebriant Posted April 21, 2004 Posted April 21, 2004 You need to derive a class from SerializationBinder and then set the Binder property on your BinaryFormatter. e.g. internal class ConvertingBinder : SerializationBinder { public override Type BindToType(string assemblyName, string typeName) { if ( assemblyName.StartsWith("MyOtherProgram") ) { return System.Type.GetType( typeName ); // Get it from this assembly } else { return System.Type.GetType( typeName + "," + assemblyName ); } } } Quote
music7611 Posted April 22, 2004 Author Posted April 22, 2004 Thanks a lot You need to derive a class from SerializationBinder and then set the Binder property on your BinaryFormatter. e.g. internal class ConvertingBinder : SerializationBinder { public override Type BindToType(string assemblyName, string typeName) { if ( assemblyName.StartsWith("MyOtherProgram") ) { return System.Type.GetType( typeName ); // Get it from this assembly } else { return System.Type.GetType( typeName + "," + assemblyName ); } } } Thanks a lot for the code! It will help a whole ton!!! I'm so excited and I can't wait to try it out. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.