需要注意的 MCSD 题目 316, 1

博客围绕Visual Studio.NET开发展开,包含三个问题及解答。一是创建自定义标签控件,需设置透明背景;二是编译调试和发布版本应用,用#if DEBUG和设置条件编译常量;三是解决Windows应用启动慢,在客户端安装后用Ngen.exe预编译。

Question

You use Visual Studio .NET to create a control that will be used on several forms in your application.
It is a custom label control that retrieves and displays your company’s current stock price.
 
The control will be displayed on many forms that have different backgrounds. You want the control
to show as much of the underlying form as possible. You want to ensure that only the stock price is
visible. The rectangular control itself should not be visible.
 
You need to add code to the Load event of the control to fulfill these requirements. Which two code
segments should you use? (Each correct answer presents part of the solution. Choose two)
 
A.  this.BackColor = Color.Transparent;
B.  this.ForeColor = Color.Transparent;
C.  this.BackImage = null;
D.  this.SetStyle(ControlStyles.UserPaint, false);
E.  this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
 
 
Answer: A, E
Explanation: 
To give your control a transparent backcolor:
1.  Call the SetStyle method of your form in the constructor. 
 
this.setStyle(ControlStyles.SupportsTransparentBackColor, true);
This will enable your control to support a transparent backcolor. 
2.  Beneath the line of code you added in step 1, add the following line. This will set your control's
BackColor to Transparent. :
 
this.BackColor = Color.Transparent;

Question

You use Visual Studio .NET to develop an application that contains 50 forms. You create a procedure
named PerformCalculations, which writes the results of several internal calculations to the Debug
window. These calculations take more than one minute to execute.
 
You want to be able to compile two versions of the application, one for debugging and the other for
release. The debugging version should execute the calculations. The release version should not include
or compile the calculations. You want to accomplish this goal by using the minimum amount of code.
 
Which two actions should you take? (Each correct answer presents part of the solution. Choose two)
 
A.  Use the following code segment:
#if DEBUG
// Insert code to perform calculations.
#endif
B.  Use the following code segment:
if (DEBUG) {
// Insert code to perform calculations.
}
C.  Use the following code segment at the top of the module:
#define DEBUG
D.  Add DEBUG = true to the Command Line Arguments box on the Debugging pane of the Project
Properties dialog box.
E.  Ensure that the Conditional Compilation Constants option in the Build pane of the Project
Properties dialog box contains the value DEBUG.
F.  Ensure that the Conditional Compilation Constants options in the Build pane of the Project
Properties dialog box includes the value TRACE.
 
 
Answer: A, E
Explanation: 
A: We should use the #if DEBUG conditionally statement wherever we want to use code that print debug
information. 
E: We enable debugging by entering DEBUG to the Conditional Compilation Constants option.
 
Reference: 
Visual Basic and Visual C# Concepts, Compiling Conditionally with Trace and Debug
C# Language Specification, Conditional compilation directives
 
Incorrect Answers
B: Incorrect syntax.
C: This would achieve the goal as well. But compared to E) it would not minimize code.
D: This is not how it is done in C#. In Visual Basic .NET you could use #CONST DEBUG = true. In
Visual C# however, you must use the DEBUG = true statement.
F:  Traces are used to trace program execution, not to print debug information.
 

Question

You develop a Windows-based application by using Visual Studio .NET. The application includes
numerous method calls at startup. After optimizing your application code, you test the application on
a variety of client computers. However, the startup time is too slow.
 
You must ensure that your application starts as quickly as possible the first time it runs. What should
you do?
 
A.  Precompile your application by using the Native Image Generator (Ngen.exe):
Install the precompiled application on the client computers.
B.  Install your application on the client computers.
Precompile your application by using the Native Image Generator (Ngen.exe).
C.  Precompile your application by using the JIT compiler.
Install the precompiled application on the client computers.
D.  Install your application on the client computers.
Precompile your application by using the JIT compiler.
 
 
Answer: B
Explanation: The Native Image Generator creates a native image from a managed assembly and installs it
into the native image cache on the local computer. Running Ngen.exe on an assembly allows the assembly
to load and execute faster, because it restores code and data structures from the native image cache rather
than generating them dynamically.
The native image contains processor-specific machine code and in this scenario a variety of client computers
are used. We must therefore use the Ngen.exe utility at the client computers after the installation, not at the
Development computer..
 
Reference: 
.NET Framework Tools, Native Image Generator (Ngen.exe)
70-306/70-316 Training kit, Installing a Native Assembly Image, Page 495
.NET Framework Developer's Guide, Compiling MSIL to Native Code
 
Incorrect Answers
A: The Native Image produced by Ngen.exe is machine-specific and in this scenario a variety of client
computers are used. We cannot use the a single Native Image from once computer on all the other
computers..
C, D: JIT (just-in-time) compilation occurs at run-time, and cannot be precompiled.
Note: When you compile a .NET application, it is not compiled to binary machine code; rather, it is
converted to IL, which is a low-level set of instructions understood by the common language run time.

When execution starts, the first bit of code that needs to be executed is loaded into memory and
compiled into native binary code from IL by the common language run time's Just-In-Time (JIT)
compiler.
 

代码下载链接: https://pan.quark.cn/s/a4b39357ea24 iSecure Center综合安防管理平台配置手册V2.0最新完整版。综合安防管理平台是一个集成了多种功能的智能化系统,通过接入视频监控、停车场、门禁以及报警检测等设备,达成安防信息化集成与联动。以电子地图作为核心载体,融合各类安防设备,达成安防信息化集成与联动。 【海康威视iSecure Center综合安防管理平台配置手册 V2.0.0】是专门针对该公司的安防管理系统而编写的详细指南。iSecure Center是一个集成化、智能化的解决方案,其目标是通过整合视频监控、停车场管理、门禁控制和报警系统等多个安全子系统,达成全面的安防信息化集成与联动。平台的核心作用是借助电子地图作为基础,整合各种安防功能,以提供高效且全面的安全监控和管理。 手册中明确指出,iSecure Center的配置和使用仅限于海康威视HIKVISION的用户,并且详细说明了版权和法律声明,强调手册内容的所有权归属于杭州海康威视数字技术股份有限公司,未经授权,禁止进行任何形式的复制、翻译或修改。同时,手册也声明了产品仅适用于中国大陆地区,并且在法律允许的范围内,产品按照现有状态提供,不提供任何形式的保证,对于因使用产品或手册所导致的损失,公司不承担任何赔偿责任。 手册还特别警示用户,将产品接入互联网可能面临风险,如网络攻击、黑客入侵或病毒感染,用户需自行承担这些风险。同时,用户必须遵守适用的法律法规,不得将产品用于侵犯第三方权利或不当用途,否则公司将不承担任何责任。 在操作前,手册提供了符号约定,包括说明、注意和危险等级的标识,帮助用户理解文档中关键信息的重要性。例如,“注意”用于提醒用户重要操作或...
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值