Unable to embed the interoperability type

Source: Internet
Author: User

During word or Excel operations, the interoperability type "…" cannot be embedded in vs2010. Use the applicable interface to solve the problem.

When I asked du Niang, the solution was exactly the same: select the DLL introduced in the project, right-click the DLL, select properties, and set "embedded interoperability type" to false. After the problem is easily solved, many people may wonder what this "embedded interoperability type" means? Next let me go slowly. (If you don't have much time, check the red font)

 

For software, interoperability-this term is used to describe different programs (programs) using the same exchange format (Exchange)
Formats) to exchange data, read and write the same file format (file formats) and the ability to use the same protocol (Protocols. (This definition of interoperability does not require the kind
The ability to execute the same binary code <binary code> on platforms> .) Lack of interoperability may be a consequence of a lack of attention to standardization during programming. In fact
World) among those that are not based on standards, interoperability is indeed not a matter of course.

According to international standards ISO/IEC 2382-01
Information technology vocabulary, basic terms (ISO/IEC 2382-01, Information Technology vocabulary, fundamental terms). interoperability is defined as follows: "the ability to communicate, execute programs, or transmit data between functional units, almost or almost without the need for users to understand the unique features of various functional units ". The above two sections are Wikipedia's explanation of "interoperability", which gives us a basic concept of "embedded interoperability type.

Next, let's talk about the "embedded interoperability type". The following is a section from the msdn magazine. It may give us some inspiration and understanding.

Embedded com interoperability type

 

This is more like the C # compiler function than the C # language function, but now you can use com to interoperate the Assembly without requiring the Assembly to exist at runtime. The purpose is to reduce the burden of deploying com interoperability assembly with your application.

When com interoperability is introduced in the first version of the. NET Framework, the concept of the main interoperability assembly (PIA) is established. This concept is introduced to solve the problem of sharing COM objects between components. For instance: If you have different interoperability sets that define an Excel worksheet, we cannot share these worksheets between components because they have different. Net types. Pia solves this problem only once: all clients use it, so
The. NET type is always matched.

Although Pia is a good idea in theory, it turns out to be a big headache in actual deployment because it only has one copy, and multiple applications may try to install or uninstall it. Because Pia is usually very large, it is more complicated. Office does not deploy them in the default Office installation method. You can easily bypass this Assembly System by Using tlbimp to create your own interoperability assembly.

Therefore, two things are happening to reverse this situation:

For two com interoperability types with the same structure and share the same recognition features (names, guids, etc.), the runtime can intelligently regard it as the same. Net type. C # the compiler uses this method to reproduce the interoperability type directly in your own program during compilation. Therefore, this interoperability assembly does not need to exist at runtime.

Due to space limitations, I have to omit some details, but even if you do not understand this information, you should be able to use this function without any obstacles, just like dynamic features. By setting the referenced "embedded interoperability type" attribute to true, you tell the compiler to embed the interoperability type into Visual Studio.

Because the C # team wants this method to be the preferred method to reference the com assembly, by default, visual Studio sets this attribute to true for any new Interoperability references added to the C # project. If you use the command line compiler (csc.exe) to compile your code, use the/l switch instead of the/R switch to embed the interoperability type in the interoperability assembly that you must reference.

All the functions described in this article can be discussed in large quantities. Each topic is worth writing an article. I have omitted a lot of details, and many details are just taken over. If we have a clear understanding of the problem, let me make a few summary. (You are welcome to add some shortcomings ).

1. "embedded interoperability type" is the meaning of introduction and import. It is similar to the using in C # And the include in C to tell the compiler whether to introduce the interoperability type.

2. The "Interoperability type" actually refers to the assembly of a series of COM components. It is a library file in the public Runtime Library, similar to compiled classes and interfaces.

3. The "embedded interoperability type" is set to true. In fact, the interoperability set is not introduced (the com assembly is abandoned during compilation), and only the user code assembly is compiled.

If it is set to false, the type information of the COM type needs to be obtained from the interoperability program set.

I don't know if you understand it...

Source: http://www.cnblogs.com/pnljs/archive/2012/02/20/2359313.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.