locked
Error "System.Runtime.Serialization.SerializationException: Unable to find assembly" RRS feed

  • Question

  • ObjectSender project is to send a class object to a message queue.
    ObjectReceiver project is to receive that class object from the message queue.
    Both ObjectSender and ObjectReceiver projects are "console application".

    I am able to send an object message (class myClass) to a message queue, but when I tried to receive the message from the message queue, I am getting the below error "System.Runtime.Serialization.SerializationException: Unable to find assembly"
    in this line of code:
    Dim obj As myClass= objMesg.getObject()

    System.Runtime.Serialization.SerializationException: Unable to find assembly ObjectSender, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.    
    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.__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, 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.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream)    
    at fiorano.csharp.util.Converter.bytesToObject(Byte[] data)    
    at fiorano.csharp.util.FioranoBinaryReader.readObject()    
    at fiorano.csharp.services.msg.FioranoObjectMessage._setDataBytes()

    I get this error either by including myClass.vb in both ObjectSender and ObjectReceiver projects, and also when I created a DLL for myClass.vb, and including that DLL in both ObjectSender and ObjectReceiver projects.

    How can I fix this error ?
    Thank you.

    Friday, September 19, 2014 8:59 PM

Answers

  • Never mind.
    The problem is solved. I created a new DLL, and included that DLL in both the ObjectSender and ObjectReceiver projects, and I don't get an error anymore. Not sure why I got the error earlier.
    Thanks.
    • Marked as answer by aujong Monday, September 22, 2014 4:22 PM
    Monday, September 22, 2014 4:22 PM

All replies

  • You say you can place something in a "message queue". Perhaps that is inaccurate. Perhaps nothing is working with that. Otherwise why would an error occur retrieving something from a "message queue"?

    And how would two different apps use the same "message queue"?

    So you provide no code for how you create a "message queue" or place something in the "message queue" which means an answer to the information you provided, which really doesn't provide anything, would be guessing at best.


    La vida loca


    Friday, September 19, 2014 9:24 PM
  • Hello,

    Beings there is a third party involved you should consider asking on their support forum.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.

    Saturday, September 20, 2014 4:18 PM
  • Thank you for your replies.

    I am using a 3rd party message queue.
    This is the code from myClass.cs

    using System;
    using System.Runtime.Serialization;
    [Serializable]
    public class MyClass 
    {
    	private string data;
    	public string getString()		
    	{			
    		return data;		
    	}
    	public void setString(string msg)		
    	{			
    		data = msg;		
    	}
    }

    This is the code from ObjectSender project

    System.Collections.Hashtable env = new System.Collections.Hashtable();
    env.Add(FioranoContext.PROVIDER_URL, url);
    FioranoNamingContext ic = new FioranoNamingContext(env);
    QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory) ic.lookup(qcf);
    Queue queue = (Queue) ic.lookup(queueName);
    QueueConnection qc = queueConnectionFactory.createQueueConnection();
    qc.setExceptionListener(new ObjectSender());
    qc.start();
    QueueSession qs = qc.createQueueSession(false, SessionConstants.AUTO_ACKNOWLEDGE);
    QueueSender sender = qs.createSender(queue);
    ObjectMessage message = qs.createObjectMessage();
    MyClass obj = new MyClass();
    for (int i = 1; i <= 2; i++)
    {
    	obj.setString("Object Message " + i);
    	message.setObject(obj);	
    	sender.send(message, DeliveryMode.PERSISTENT, 4, 0);
    }

    This is the code from ObjectReceiver project

    System.Collections.Hashtable env = new System.Collections.Hashtable();
    env.Add(FioranoContext.PROVIDER_URL, url);
    FioranoNamingContext ic = new FioranoNamingContext(env);
    QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory) ic.lookup(qcf);
    Queue queue = (Queue) ic.lookup(queueName);
    QueueConnection queueConnection = queueConnectionFactory.createQueueConnection();
    queueConnection.setClientID("Object_Receiver");
    queueConnection.setExceptionListener(new ObjectReceiver());
    queueConnection.start();
    QueueSession queueSession = queueConnection.createQueueSession(false, SessionConstants.AUTO_ACKNOWLEDGE);
    QueueReceiver queueReceiver = queueSession.createReceiver(queue);
    for (int i = 1; i <= 10; i++)
    {
    	ObjectMessage objMesg = (ObjectMessage) queueReceiver.receive();
    	MyClass obj = (MyClass) objMesg.getObject();
      -->>> ERROR HERE
    Once I put myClass.DLL in GAC, I don't get the error anymore. This is what I did:
    1. I created a class library myClass
    2. In myClass project property, in the Signing tab, I clicked "Sign the assembly", and click "New" in the "Choose a strong name key file", entered the key file name and its password.
    3. Build myClass.DLL
    4. Go to command prompt, and type in this:
     gacutil -i "C:\myFolder\myClass.DLL"
    After this, I don't get the error message anymore  in this line of code:
    MyClass obj = (MyClass) objMesg.getObject()


    So, just by putting either myClass.cs in both ObjectSender and ObjectReceiver projects, or by putting myClass.DLL in the same folder with the ObjectSender and ObjectReceiver EXEs, that's not the same with having it in GAC ?


    Monday, September 22, 2014 1:57 PM
  • That's all C# code isn't it? This is a VB.Net forum. If you want to post questions about C# code try using the C# forum possibly.

    Google search results for "GAC MSDN"


    La vida loca


    Monday, September 22, 2014 2:12 PM
  • Oh..so sorry..the same problem happens in VB.NET

    This is the VB.NET code for the class

    <Serializable()> _
        Public Class myClass
        Public AccountID As String
        Public PrimaryAddressLine1 As String
    This is the code for the ObjectSender project
    Dim env As Hashtable = New Hashtable()
    env.Add(FioranoContext.PROVIDER_URL, url)
    Dim ic As FioranoNamingContext = New FioranoNamingContext(env)
    Dim queueConnectionFactory As QueueConnectionFactory = ic.lookup(qcf)
    Dim queue As fiorano.csharp.fms.Queue = ic.lookup(queueName)
    Dim qc As QueueConnection = queueConnectionFactory.createQueueConnection()
    qc.setExceptionListener(New QSenderObjectVB)
    qc.start()
    
    Dim qs As QueueSession = qc.createQueueSession(False, SessionConstants.AUTO_ACKNOWLEDGE)
    Dim sender As QueueSender = qs.createSender(queue)
    Dim message As ObjectMessage = qs.createObjectMessage
    Dim obj As clsAccount = New myClass
    For i As Integer = 0 To 1
        Try
            obj.AccountID = "Account " & i
            obj.PrimaryAddressLine1 = "Address " & i
            message.setObject(obj)
            sender.send(message, DeliveryMode.PERSISTENT, 4, 0)
        Catch ex As Exception
            Console.WriteLine(ex)
        End Try
    Next

    This is the code for the ObjectReceiver project
    Dim env As Hashtable = New Hashtable()
    env.Add(FioranoContext.PROVIDER_URL, url)
    Dim ic As FioranoNamingContext = New FioranoNamingContext(env)
    Dim queueConnectionFactory As QueueConnectionFactory = ic.lookup(qcf)
    Dim queue As fiorano.csharp.fms.Queue = ic.lookup(queueName)
    Dim queueConnection As QueueConnection = queueConnectionFactory.createQueueConnection()
    queueConnection.setClientID("Object_Receiver")
    queueConnection.setExceptionListener(New QReceiverObjectVB)
    queueConnection.start()
    Dim QueueSession As QueueSession = queueConnection.createQueueSession(False, SessionConstants.AUTO_ACKNOWLEDGE)
    Dim queueReceiver As QueueReceiver = QueueSession.createReceiver(queue)
    While (True)
        Try
          Dim objMesg As ObjectMessage = queueReceiver.receive
          Dim obj As myClass = objMesg.getObject()  ---> ERROR HERE
    Catch ex As Exception
    End Try
    End While


    • Edited by aujong Monday, September 22, 2014 2:40 PM
    Monday, September 22, 2014 2:30 PM
  • Never mind.
    The problem is solved. I created a new DLL, and included that DLL in both the ObjectSender and ObjectReceiver projects, and I don't get an error anymore. Not sure why I got the error earlier.
    Thanks.
    • Marked as answer by aujong Monday, September 22, 2014 4:22 PM
    Monday, September 22, 2014 4:22 PM
  • Never mind.
    The problem is solved. I created a new DLL, and included that DLL in both the ObjectSender and ObjectReceiver projects, and I don't get an error anymore. Not sure why I got the error earlier.
    Thanks.

    Maybe because your .Dll isn't registered on the system. But now that you've placed it in the projects it can be found.

    Dynamic-Link Library Search Order


    La vida loca

    Monday, September 22, 2014 4:38 PM
  • I also included the earlier DLL in both projects, but got an error earlier.
    But, the problem is fixed now.
    Thanks all for your help.
    Tuesday, September 23, 2014 4:25 PM