tailieunhanh - Expert C++/CLI .NET for Visual C++ Programmers phần 6

Nếu cơ sở xác định hoặc được thừa hưởng một e chức năng ảo và chữ ký như Điều này cho phép bạn khởi tạo một biến gcroot với một FileSystemWatcher ^ xử lý. Các mã sau đây sử dụng xây dựng để thực hiện các constructor của ChangedFileDumper lớp | CHAPTER 7 USING C CLI TO EXTEND VISUAL C PROJECTS WITH MANAGED CODE 157 clr clr pure clr safe Must the assembly be loaded by the OS loader for all dependent DLLs to be loaded correctly Yes No No unless you produce a mixed-code assembly because of other linker inputs that were compiled with clr or to native code Can the assembly be loaded via System Reflection Assembly Load From DLL Yes EXE No Yes Yes unless you produce a mixed-code EXE Does the resulting assembly depend on the C C runtime DLLs Yes Yes No unless you produce a mixed-code assembly Can the compilation model be used for extending existing projects with .NET features Yes No No Can the assembly export functions to native clients Yes No No Can the compilation model be used for wrapping native libraries Yes unless Yes but it you want to makes sense host in only in rare customized CLR scenarios environments like SQL Server 2005 or unless you have to execute in restricted CAS environments Yes but it can be a lot of work and makes sense only if the assembly is executed in a restricted CAS environment Step by Step The next sections introduce a step-by-step approach that I recommend for reconfiguring a project for C CLI. This approach has several goals as follows Partial migration and short iterations in this context iteration is the timeframe from one buildable and testable state of your project to the next. Shorter iterations give you more options to test your project s output. If a test fails it is likely caused by changes made since the last iteration. This can simplify the error tracking significantly. Minimizing impact on existing code. Minimizing overhead of managed execution. 158 CHAPTER 7 USING C CLI TO EXTEND VISUAL C PROJECTS WITH MANAGED CODE Step 1 Modifying Settings at the Project Level To migrate to managed compilation you should start by modifying properties at the project level. Project-level properties are inherited by all project items source files however for a project item you can explicitly