Labels

Tuesday, August 31, 2010

Using Reserved Words in VB.Net

Up until now, if I wanted to use a reserved keyword as a variable, function or property name (such as Public Property ReadOnly() As Boolean), the compiler would complain.

Luckily I happened across a very simple answer yesterday; VB.Net works in a similar way to SQL - to use a reserved word as an identifier, just put square brackets around it!

i.e. Public Property [ReadOnly]() As Boolean

Friday, August 27, 2010

#1 Practice test questions for Certification Exam 70-536‏

QUESTIONS Technology Focus: Developing applications that use system types and collections
1. You are developing a text processing application by using the .NET Framework. You write the following code to iterate over a collection of strings and populate a ListBox control with the values it contains (line numbers are for reference only). The GetStrings function returns an array of strings.
C#
01: StringCollection myStrCol = new StringCollection();
02: myStrCol.AddRange(GetStrings());
03: StringEnumerator myEnumerator = myStrCol.GetEnumerator();

Visual Basic
01: Dim myStrCol As StringCollection = New StringCollection()
02: myStrCol.AddRange(GetStrings())
03: Dim myEnumerator As StringEnumerator = myStrCol.GetEnumerator()
You need to add code to populate the ListBox control. What code should you add?
Option A

C#
while (myEnumerator.MoveNext())
      lstStrings.Items.Add(myEnumerator.Current);

Visual Basic
While (myEnumerator.MoveNext())
   lstStrings.Items.Add(myEnumerator.Current)
End While
Option B

C#
do
{
   lstStrings.items.Add(myEnumerator.Current)
} while (myEnumerator.MoveNext())

Visual Basic
Do
   lstStrings.items.Add(myEnumerator.Current)
Loop While (myEnumerator.MoveNext())
Option C

C#
myEnumerator.Reset();
do
{
   lstStrings.items.Add(myEnumerator.Current)
} while (myEnumerator.MoveNext())

Visual Basic
myEnumerator.Reset()
Do
   lstStrings.items.Add(myEnumerator.Current)
Loop While (myEnumerator.MoveNext())
Option D

C#
do
{
   lstStrings.items.Add(myEnumerator.Current)
   myEnumerator.Reset();
} while (myEnumerator.MoveNext())

Visual Basic
myEnumerator.Reset()
Do
   lstStrings.items.Add(myEnumerator.Current)
Loop Until (myEnumerator.MoveNext())

2. You are developing a .NET Framework application that uses the Stack class. You need to write code that enumerates through the stack.Your code must guarantee thread safety during the enumeration. Which code segment should you use?
Option A

C#
Stack myStack = new Stack();
lock (myStack.SyncRoot)
{
    foreach (Object item in myStack)
    {
        // additional code for processing.
    }
}

Visual Basic
Dim myStack As Stack = New Stack()
SyncLock myStack.SyncRoot
    For Each item As Object In myStack
        ' additional code for processing.
    Next
End SyncLock
Option B

C#
Stack myStack = new Stack();
Stack syncStack = Stack.Synchronized(myStack);
foreach (Object item in syncStack)
{
   // additional code for processing.
}

Visual Basic
Dim myStack As Stack = New Stack()
Dim syncStack As Stack = Stack.Synchronized(myStack)
For Each item As Object In syncStack
    ' additional code for processing.
Next
Option C

C#
Stack myStack = new Stack();
Stack syncStack = (Stack) myStack.SyncRoot;
foreach (Object item in syncStack)
{
    // additional code for processing.
}

Visual Basic
Dim myStack As Stack = New Stack()
Dim syncStack As Stack = myStack.SyncRoot
For Each item As Object In syncStack
    ' additional code for processing.
Next
Option D

C#
Stack myStack = new Stack();
lock (Stack.Synchronized(myStack))
{
    foreach (Object item in myStack)
    {
        // additional code for processing.
    }
}

Visual Basic
Dim myStack As Stack = New Stack()
SyncLock (Stack.Synchronized(myStack))
    For Each item As Object In myStack
        ' additional code for processing.
    Next
End SyncLock

3. You are creating a class library that will be used by several applications. You need to create a custom exception that will be thrown if an application attempts to retrieve product information using an invalid product number.
You need to create the ProductNotFoundException class. From which class should you derive ProductNotFoundException?
A: ApplicationException
B: SystemException
C: Exception
D: ArgumentException

#2 Practice test questions for Certification Exam 70-536‏

QUESTIONS Technology Focus: Implementing service processes, threading, and applications domains in a .NET Framework application
1. You create a Windows service application that consists of two services. One service monitors a directory for new orders and the other service replicates a database table with the most up-to-date inventory information.You need to develop a project installer class to install these services.What should you do? (Each correct answer presents part of the solution. Choose two.).

A. Instantiate one ServiceProcessInstaller instance and add it to the project installer class.

B. Instantiate two ServiceInstaller instances and add them to the project installer class.
C. Instantiate two ServiceProcessInstaller instances and add them to the project installer class.
D. Instantiate one ServiceInstaller instance and add it to the project installer class.
E. Instantiate one ComponentInstaller instance and add it to the project installer class.
F. Instantiate two ComponentInstaller instances and add them to the project installer class.


2. You are developing a Windows service application by using the .NET Framework. You need the application to perform several short tasks that require background processing. You do not want to actively manage threads in your application. You must ensure that security checks are performed during the execution of a task. Which method should you use to start a task in your application?
A. ThreadPool.QueueUserWorkItem
B. ThreadPool.UnsafeQueueUserWorkItem
C. Thread.Start
D. Thread.Resume


3. You are developing a Windows service application by using the .NET Framework. You need to synchronize execution of some resources across multiple processes. Which class should you use to accomplish this in your application?
A. Mutex
B. Monitor
C. Interlocked
D. Mutex

#3 Practice Questions and Discussion for Exam 70-536

QUESTIONS Technology Focus: Embedding configuration, diagnostic, management, and installation features into a .NET Framework application

1. You develop a Windows application by using the .NET Framework. The application makes use of an assembly named MyAssembly. The assembly file MyAssembly.d11 is deployed in a folder named bin20 under the application's root directory. The MyAssembly assembly is not strongly named.
You must configure the Windows application to specify the location of the MyAssembly assembly. Any settings that you change must not affect other applications installed on the system. What should you do?
A. Modify the application configuration file to add the following settings to the <assemblyBinding> section: <probing privatePath="bin20"/>
B. Modify the application configuration file to add the following settings to the <assemblyBinding> section: <probing privatePath="bin20"/MyAssembly.d11"/>>
C. Modify the machine configuration file and add the following settings to the <assemblyBinding> section for the MyAssembly assembly: <codeBase href="bin20/myAssembly.d11"/>
D. Modify the machine configuration file and add the following settings to the <assemblyBinding> section for the MyAssembly assembly: <codeBase href="bin20"/>

2. You have deployed an application that uses a dependent assembly named TaxCalc. It was written to work with version 1.1.3.6 of TaxCalc, but has been tested successfully through version 2.1.1.0. The user updates the TaxCalc assembly to version 2.1.1.2 and your application no longer runs.
Several other applications on the computer use TaxCalc. The other applications on the computer can run with the new version of TaxCalc.You need to ensure that your application works with a supported version of TaxCalc that is installed on the computer. Your solution should allow other applications to continue to use the latest version of TaxCalc.What should you do?
A. Add the following to the publisher configuration file for the TaxCalc assembly:
    
<dependentAssembly>
   <assemblyIdentity type="win32" processorArchitecture="x86"
name="TaxCalc"
publicKeyToken="12345abcde12345bcdef12345abcde" />
      <bindingRedirect oldVersion="2.1.1.2" newVersion="2.1.1.0" 
/>
</dependentAssembly>
B. Add the following to the application configuration file:
<dependentAssembly>
   <assemblyIdentity type="win32" processorArchitecture="x86" name="TaxCalc" 
publicKeyToken="12345abcde12345bcdef12345abcde" oldVersion="1.1.3.6-2.1.1.2" 
newVersion="2.1.1.0" />
</dependentAssembly
C. Add the following to the application configuration file:
<dependentAssembly>
   <assemblyIdentity type="win32" processorArchitecture="x86" name="TaxCalc" 
publicKeyToken="12345abcde12345bcdef12345abcde" />
      <bindingRedirect oldVersion="2.1.1.2" newVersion="2.1.1.0" />
</dependentAssembly>
D. Add the following to the publisher configuration file:
<dependentAssembly>
   <assemblyIdentity type="win32" processorArchitecture="x86" name="TaxCalc" 
publicKeyToken="12345abcde12345bcdef12345abcde" oldVersion="2.1.1.2" 
newVersion="1.1.3.6-2.1.1.0" />
</dependentAssembly>

3. You are developing a .NET Framework application. When a user's attempt to log on to the application fails, you must write an entry to the Windows event log. When looking at the Windows event log viewer, the source of the events must be listed as MyApp.You need to create an event source that can be used to write entries to the event log. Which code segment should you use?
Option A
C# 
EventLog.LogNameFromSourceName("MyApp", "Security");
Visual Basic
EventLog.LogNameFromSourceName("MyApp", "Security")
Option B
C# 
if(!EventLog.SourceExists("MyApp"))
{
  EventLog.CreateEventSource("MyApp", "Application");
}
Visual Basic
If Not EventLog.SourceExists("MyApp") Then
    EventLog.CreateEventSource("MyApp", "Application")
End If
Option C
C# 
if(!EventLog.SourceExists("MyApp"))
{
  EventLog.CreateEventSource("MyApp", "Security");
}
Visual Basic
If Not EventLog.SourceExists("MyApp") Then
    EventLog.CreateEventSource("MyApp", "Security")
End If
Option D
C# 
EventLog.LogNameFromSourceName("MyApp", "Application");
Visual Basic
EventLog.LogNameFromSourceName("MyApp", "Application")

Wednesday, August 25, 2010

ASP.Net File Upload failed on IIS7 & Windows 2008

Error:
Request object error
'ASP 0104 : 80004005' Operation not Allowed

Reason:
IIS6.0 prevents the upload of files more than +200Kb. So you need to make some changes in the default IIS settings first.

Background:
For IIS6.0 users, the AspMaxRequestEntityAllowed property specifies the maximum number of bytes allowed in the entity body of an ASP request. If a Content-Length header is present and specifies an amount of data greater than the value of AspMaxRequestEntityAllowed, IIS returns a 403 error response. This property is related in function to MaxRequestEntityAllowed, but is specific to ASP request. Whereas you might set the MaxRequestEntityAllowed property to 1 MB at the general World Wide Web Publishing Service (WWW Service) level, you may choose to set AspMaxRequestEntityAllowed to a lower value, if you know that your specific ASP applications handle a smaller amount of data.

Solution:
Open your metabase.XML which is located in c:\Windows\System32\Inetsrv find the line "AspMaxRequestEntityAllowed" and change it to "1073741824". This is 1GB - of course you can enter another value to suite your needs. NOTE: Before you edit the file, be sure to stop the IIS service first or else you won't be able to save the file.

Thursday, August 19, 2010

BLJC Questions

1. UML

2. ASP.Net Authentication
 Forms Authentication, Passport Authentication,Windows Authentication.
 To enable a specified authentication provider for an ASP.NET application, you must create an entry in the application's configuration file as follows:
 // web.config file
<authentication mode = "[Windows/Forms/Passport/None]">
</authentication>

IIS Authentication:
Basic, Integrated(NTLM/Kerb) , Digist, Certificate Mapping, Anonymous

Authorization
    * Using Windows ACLs
    * Using URL Authorization
    * Using .NET Principal Objects

3. Steps to call VB COM in C#
 register COM -> Add reference -> Using namespace -> Earlier/later binding

4. what's the possible pattern to replace long Switch code
 
Programming Test:
1. Validation ASP.net form
2. OO design and OO Programming, COM written in C# shared by VB and .Net

Thursday, August 5, 2010

The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.

.Net call VB6 DLL insert into SQL Server got this error
change region setting -> date format to match SQL server database setting