error: Could not load the file or assembly 'ExcelAddIn1.XmlSerializers' or one of it's dependencies. The system cannot find the file specified

I have an Add-in project for excel. It works fine on my computer. But when I install it on a client machine it gives me the error message i mentioned.

  1. I have Published it using project-> properties-> publish.
  2. I have the 'Enable Just my code' ticked.
  3. I have cleared the ticks for 'thrown' and 'user-unhandled' for the 'file not found exception'
  4. I setup the project on the client with the "setup" file in the "publish" folder in my project folder.
  5. In publish-> prerequisites, I have these items ticked:

    .net framework sp1

    Microsoft .net framework 4

    Microsoft office 2007 primary interop assemblies

    Microsoft visual studio 2010 tools for office runtime

    Windows installer 4.5

  6. I'm using JSON. this is the code for my class:

    public class documentSchemaRestInfo
        public double id { get; set; }
        public string name { get; set; }
        public string description { get; set; }
        public string[] fields { get; set; }


  7. The code that uses the class:

    public List<DocumentField> getSchemaOfGroup(documentGroupPk groupPK)
        List<DocumentField> result = new List<DocumentField>();
        HttpWebRequest request = (HttpWebRequest)WebRequest.
            + + "/schema");
        HttpWebResponse response = (HttpWebResponse)request.GetResponse();
        StreamReader streamReader = new StreamReader(response.GetResponseStream());
        string responseBody = streamReader.ReadToEnd();
        dynamic ds = ((dynamic)JsonConvert.DeserializeObject(responseBody))
        foreach (dynamic f in ds.fields)
            result.Add(new DocumentField(
        return result;
  8. The client machine has Excel 2010 installed on it.

  9. This is the line of code throwing the exception:

       excelApp = (Excel.Application) 
  10. What is weird is that it works when I follow the following steps: Run it on the client and get an exception. Run it on my own PC (where no exception occurs). Press the add-in button on the Excel ribbon I made, on the client machine's application AND THIS TIME I DON'T GET ANY EXCEPTION!! I checked it so many times. Every time I follow this order it works fine!


Thanks a lot in advance.

Edit: 12. My application works like this: The first time user clicks on my button on the ribbon, the login form appears, and if he is authorized the form he has asked for appears. The next times just the asked form appears. and the exception happens JUST the first time clicks. here is my code for that: (No exception occurs in the last line, but that's not the case with the case with the 7th line)

            1.//If there is no ticket, means we haven't had a successfull login yet.=> 
            2.// We should show the login form instead of groups form.
            3.if (string.IsNullOrEmpty(ProxyFactory.ticket))
            5.  okOrCancel = new LoginForm().ShowDialog();
            6.    if (okOrCancel == DialogResult.OK)
            7.        new GroupsForm().ShowDialog();
            9.//If the is a ticket, means we have had a successful login.
            11.    new GroupsForm().ShowDialog();


It's wee bit confusing looking just at the code spinets but from the title of the question I can guess that you have a problem with dynamic creation of serialization assembly (security issue or partial trust issue). You can try turning "Generate serialization assembly" in your Addin dll to Off by going to project properties / Build and selecting Off from the list.

Need Your Help

Check if scroll is triggered or not

javascript jquery html mousewheel

I am building a website and in this website I have an event on my mousewheel. The problem is that when you scroll your mouse on a mac (with a magic mouse) the scroll event is called so many times t...

Python multiprocessing stdin input

windows python-3.x process multiprocessing stdin

All code written and tested on python 3.4 windows 7.