Error: Failed to load the file or assembly "ExcelAddIn1.XmlSerializers" or one of these dependencies. The system cannot find the specified file.

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

  • I published it using project-> properties-> publish.
  • I have a checkbox labeled "Include only my code."
  • I cleared the ticks for the “abandoned” and “user-unhandled” for the “not found exceptions”
  • I am setting up a project on the client with the “setup” file in the “publish” folder in the project folder.
  • In publish-> prerequisites, I have these elements:

    .net framework sp1

    Microsoft.net framework 4

    Primary Prefabricated Assemblies for Microsoft Office 2007

    Microsoft visual studio 2010 for office time

    Windows Installer 4.5

  • I am using JSON. this is the code for my class:

    [Serializable] [JsonObject(MemberSerialization.OptIn)] public class documentSchemaRestInfo { [System.Runtime.Serialization.DataMember] [JsonProperty] public double id { get; set; } [System.Runtime.Serialization.DataMember] [JsonProperty] public string name { get; set; } [System.Runtime.Serialization.DataMember] [JsonProperty] public string description { get; set; } [System.Runtime.Serialization.DataMember] [JsonProperty] public string[] fields { get; set; } } 

    // ************************************************ ************

  • Code that uses the class:

     public List<DocumentField> getSchemaOfGroup(documentGroupPk groupPK) { List<DocumentField> result = new List<DocumentField>(); HttpWebRequest request = (HttpWebRequest)WebRequest. Create(ProxyFactory.baseAddress+"/services/rest/group/" + groupPK.id + "/schema"); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); StreamReader streamReader = new StreamReader(response.GetResponseStream()); string responseBody = streamReader.ReadToEnd(); dynamic ds = ((dynamic)JsonConvert.DeserializeObject(responseBody)) .documentSchemaRestInfo; foreach (dynamic f in ds.fields) { result.Add(new DocumentField( f.name.ToString(),f.internalName.ToString(),false)); } return result; } 
  • Excel 2010 is installed on the client computer.

  • This is a line of code that throws an exception:

      excelApp = (Excel.Application) System.Runtime.InteropServices.Marshal.GetActiveObject ("Excel.Application"); 
  • What is strange is that it works when I follow these steps: Run it on the client and get an exception. Run it on my own computer (where the exception does not occur). Click the add-in button on the Excel ribbon that I made on the client machine application AND THIS TIME I DO NOT GET ANY EXCEPTION !! I checked it so many times. Every time I follow this order, it works great!

eleven. This is the stack trace of the exception

Thank you very much in advance.

Edit: 12. My application works as follows: The first time a user clicks on my button on the ribbon, a login form appears, and if he is authorized, the application that he asked appears. The next time only the requested form appears. and the exception occurs JUST for the first time. here is my code for this: (An exception does not occur on the last line, but this does not apply to 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)) 4.{ 5. okOrCancel = new LoginForm().ShowDialog(); 6. if (okOrCancel == DialogResult.OK) 7. new GroupsForm().ShowDialog(); 8.} 9.//If the is a ticket, means we have had a successful login. 10.else 11. new GroupsForm().ShowDialog(); 
+6
source share
5 answers

This is a bit confusing, looking only at code spinets, but from the title of the question, I can guess that you had a problem with dynamically creating a serialization assembly (security problem or partial trust problem). You can try turning the "Generate serialization assembly" in your Addin dll to Off by going to the project / Build properties and selecting Off from the list.

+2
source

Have you included a link to System.Runtime.Serialization ?

0
source

Are you sure the client has .NET 4.0 installed?

0
source

I never did add Excel, but I created several Visual Studio extensions, and the error reminds me at the time when I mixed up the registry paths for the extensions. There are two ways for VS in the registry: one for 64-bit and one for 32-bit.

Have you checked the registry?

http://msdn.microsoft.com/de-de/library/bb386106(VS.90).aspx

0
source

Try

project> Properties> Assembly tab> Create Serialization Assembly> Disabled

0
source

Source: https://habr.com/ru/post/902753/


All Articles