What should you do to ensure that the assembly functions without propagating errors in both standalone?

You create an assembly by using Microsoft .NET Framework 3.5.
The assembly creates a new text file in the root of the C: drive. The assembly will be used in a Windows Presentation Foundation standalone application. The assembly will also be used in a Windows Presentation Foundation XAML Browser Application (XBAP).
The assembly contains the following code segment.
(Line numbers are included for reference only.)

01 public void Save()
02 {
03
04 FileStream stream = File.Create("c:newfile.txt");
05 try
06 {
07 StreamWriter writer = new StreamWriter(stream);
08 try
09 {
10 writer.WriteLine("Bew line in text file");
11 }
12 finally
13 {
14 writer.Dispose();
15 }
16 }
17 finally
18 {
19 stream.Dispose();
20 }
21
22 }

You need to ensure that the assembly functions without propagating errors in both standalone and XBAP applications.
What should you do?

You create an assembly by using Microsoft .NET Framework 3.5.
The assembly creates a new text file in the root of the C: drive. The assembly will be used in a Windows Presentation Foundation standalone application. The assembly will also be used in a Windows Presentation Foundation XAML Browser Application (XBAP).
The assembly contains the following code segment.
(Line numbers are included for reference only.)

01 public void Save()
02 {
03
04 FileStream stream = File.Create(“c:newfile.txt”);
05 try
06 {
07 StreamWriter writer = new StreamWriter(stream);
08 try
09 {
10 writer.WriteLine(“Bew line in text file”);
11 }
12 finally
13 {
14 writer.Dispose();
15 }
16 }
17 finally
18 {
19 stream.Dispose();
20 }
21
22 }

You need to ensure that the assembly functions without propagating errors in both standalone and XBAP applications.
What should you do?

A.
Configure the assembly to use the Nothing Permission set.

B.
Configure the assembly to use the Partial Trust Permission set.

C.
Demand the FileIOPermissionAccess.Write permission in line 03 and add an exception handler at line 21.

D.
Demand the FileIOPermissionAccess.Append permission in line 03 and add an exception handler at line 21.



Leave a Reply 0

Your email address will not be published. Required fields are marked *