The input stream is not a valid binary format. The starting contents (in bytes) are: 53-79-73-74-65-6D-2E-52-75-6E-74-69-6D-65-2E-52-65

StackOverflow https://stackoverflow.com/questions/16181527

  •  11-04-2022
  •  | 
  •  

Frage

I have a VSTO Word Addin project which integrates with the Word 2007, when I click on login button on my Addin, I execute the following method:

    private void btnOK_Click(object sender, System.EventArgs e)
    {
        AuditDataAccess auditDataAccess = 
(AuditDataAccess)DataAccessFactory.GetNewInstance(typeof(AuditDataAccess));
    }

Here, DataAccessFactory is a class in another referenced assembly named RemoteData as follows:

public class DataAccessFactory
{
    static DataAccessFactory()
        {
            objADDataAccess = new ADDataAccess();
        }
}

Here, ADDataAccess is a class in the same assembly RemoteData as:

namespace RemoteData.Client
{
    public class ADDataAccess : IDataAccess
        {
            RemoteData.Server.ADDataAccess proxy = null;

            internal  ADDataAccess()
            {
                proxy = new RemoteData.Server.ADDataAccess(); // Error Line
            }
         }

public interface IDataAccess
    {
        bool IsActive
        {
            get;
        }
    }

}

Server.ADDataAccess is in the same assembly RemoteData as:

namespace RemoteData.Server
{
    public class ADDataAccess:DataAccess
    {
        DataAccess.ADDataAccess objDataAccess;


        public ADDataAccess()
        {
            //objDataAccess = new DataAccess.ADDataAccess();
        }
    }
public abstract class DataAccess : MarshalByRefObject
    {
        public bool IsActive
        {
            get { return true; }
        }
    }
}

I have commented the code for new DataAccess.ADDataAccess() which is creating a new object of a class in another reference assembly named DataAccess, thinking that this might be the one creating the problem, but I am still receiving the same error mentioned in the question header on the line commented as Error Line

EDIT: I have created a small project with the same architecture and it is working fine. Here is the download link: http://www.2shared.com/file/dGXNtsAK/Server.html

Please please help...

War es hilfreich?

Lösung

This issue is resolved. The problem was that in the Project.dll.config file, there was a configuration of remoting like this:

<system.runtime.remoting>
        <application>
            <channels>
                <channel ref="http">
                    <clientProviders>
                        <formatter ref="binary"/>
                    </clientProviders>
                </channel>
            </channels>
            <client url="" displayName="">
                <activated />
            </client>
        </application>
    </system.runtime.remoting>

As, we were directly instantiating the types exposed via the <activated/> elements in it, rather than getting them via remote calls, so it was causing an exception. After commenting the entire remoting configuration section in web.config, it started working.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top