Cannot embed interaction types from assembly

I know that similar questions have been asked here before, but I'm not sure that they really solve my problem if I do not understand them.

I am working on the application this morning, and I had no problems creating or restoring the solution, but after I went for lunch and then returned (I left the program open), I suddenly could not build it, since it returns 3 mistakes that I have not encountered before.

Error 1:

You cannot embed interop types from the 'office' assembly because the attribute 'ImportedFromTypeLib' or the attribute 'PrimaryInteropAssembly' is missing.

Error 2:

Cannot embed interop types from the 'office' assembly because the 'Guid' attribute is missing

Error 3:

Unable to load link library C: \ WINDOWS \ assembly \ GAC_MSIL \ Office \ 15.0.0.0__71e9bce111e9429c \ Office.dll ': the system cannot find the specified file. C: \ WINDOWS \ assembly \ GAC_MSIL \ Office \ 15.0.0.0__71e9bce111e9429c \ Office.dll

What causes these errors all of a sudden?

After checking in the project properties> Link> Add> COM, I see that the Office 15.0 object library is referenced. So what should I do? It seems strange that they appeared while the application was open?

+5
source share
5 answers

Just because it is not indicated for the rest of eternity and for any potential future users with the same problem, the answer, as suggested by @soohoonigan and @TnTinMn:

  • Clean and restore solution.
  • , .
+9

- "true", "false". , , "true".

+2

1 2, , , :

→ Microsoft.CSharp → - " Interop" "False", .

+2

, . , Embed Interop Types "true". & , , "".

0

The actual problem is that the link in your solution is configured to embed interaction types in the target assembly! just check the properties of your links and set this flag to false for all of them.

0
source

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


All Articles