Blog Home  Home Feed your aggregator (RSS 2.0)  
Software Code Help blogs - Thursday, November 06, 2008
newtelligence powered
 
 Thursday, November 06, 2008

1. In the assembly that implements the type(Console), look up the method being called in the metadata.
2. From the metadata, get the IL from this method and verify it.
3. Allocate a block of memory.
4. Compile the IL into native CPU instructions: the native code is saved in the memory allocated in step#3.
5. Modify the method's entry in the Type's table so that it now points to the memory block allocated in Step#3.
6. Jump to the native code contained inside the memory block.

Thursday, November 06, 2008 5:25:33 AM (GMT Standard Time, UTC+00:00)  #    Comments [0]   C#  | 

Declare @Var1 nvarchar(800)

 

Set @Var1=’’

 

Select @Var1 = @Var1 + ‘,’ + Field1 from Table1

 

Select @Var1

Thursday, November 06, 2008 4:56:38 AM (GMT Standard Time, UTC+00:00)  #    Comments [0]   SQL  | 
 Monday, October 13, 2008

Problem:

I am getting following error while running the project in Visual Studio 2005 by hitting F5

"Unable to strat debugging on the web server.  The COM+ registry database detected a system error."

what can be the cause?

 

Answer

 

After searching some internet,
I added the ASPNET user to Local Administrator group and restarted IIS and it started working.

However somewhere it is written that even after removing from Administrator group it kept on working, but not in my case. I removed from the group and restarted IIS and it stopped working again.

Monday, October 13, 2008 10:28:18 AM (GMT Standard Time, UTC+00:00)  #    Comments [0]    | 
 Wednesday, September 17, 2008

Hi,

Whenever I run sfc /scannow it asks for a CD. How can i point it to some other path where my installation source files reside.

Answer:

In Registry using regedit locate

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\
CurrentVersion\Setup\SourcePath

Set its value to the location where I386 foler is located. Provide the parent folder path of I386 and not of I386 itself.

Also update ServicePackSourcePath and add to Installation Sources as well.

Wednesday, September 17, 2008 11:41:06 AM (GMT Standard Time, UTC+00:00)  #    Comments [0]    | 
 Monday, September 01, 2008

Question:

 

HI,

I have got a strange problem. I am opening a webpage using javascript's showModelessDialog fuction. the page contains a calender.

When I click a date on calender (opened with showModelessDialog) it openes a new window showing the javascript function like: javascript:__doPostBack('MyCalendar','3132')

Please provide your valuable comments.

 

Answer:

 

 

use :

<base target="_self">

in the showModelessDialog or showModalDialog page in head section.

Monday, September 01, 2008 3:57:27 AM (GMT Standard Time, UTC+00:00)  #    Comments [0]    | 

here is the working code:

<form id="form1" runat="server">

<div>

<asp:TextBox runat="server" ID="txt1" TextMode="MultiLine" />

<asp:HiddenField runat="server" ID="hidSelectedText" />

<asp:Button runat="server" ID="showselected" Text="Show selected" OnClientClick="doselection();" OnClick="showselected_Click" />

<script type="text/javascript">

function doselection()

{

if (window.getSelection)

{

txt = window.getSelection();

}

else if (document.getSelection)

{

txt = document.getSelection();

}

else if (document.selection)

{

txt = document.selection.createRange().text;

}

else

{

alert('selection not supported');

}

document.getElementById('<%=hidSelectedText.ClientID %>').value = txt;

}

</script>

</div>

</form>

 

-----------------------------------------------------------------------

protected void showselected_Click(object sender, EventArgs e)

{

Response.Write(hidSelectedText.Value);

}

Monday, September 01, 2008 3:50:18 AM (GMT Standard Time, UTC+00:00)  #    Comments [0]    | 
 Wednesday, August 13, 2008

Go to

Tools > Options 

Expand "Projects And Solutions"

Check "Track Active item in Solution Explorer"

 

Wednesday, August 13, 2008 4:57:41 AM (GMT Standard Time, UTC+00:00)  #    Comments [0]    | 
 Friday, August 01, 2008

Use

Server.UrlEncode

Friday, August 01, 2008 1:50:01 PM (GMT Standard Time, UTC+00:00)  #    Comments [0]   C# | Interview Question ASP.NET  | 

Virtual method has an implementation & provide the derived class with the option of overriding it.

 

Abstract method does not provide an implementation & forces the derived class to override the method.

Friday, August 01, 2008 11:02:21 AM (GMT Standard Time, UTC+00:00)  #    Comments [0]   Interview Question .NET  | 

Windows Authentication (via Active Directory) and SQL Server authentication (via Microsoft SQL Server username and password).

Windows Authentication is trusted because the username and password are checked with the Active Directory,

 

the SQL Server authentication is untrusted, since SQL Server is the only verifier participating in the transaction.

Friday, August 01, 2008 10:53:44 AM (GMT Standard Time, UTC+00:00)  #    Comments [0]   SQL  | 

1. Positive test cases (correct data, correct output).


2. Negative test cases (broken or missing data, proper handling).


3. Exception test cases (exceptions are thrown and caught properly).

Friday, August 01, 2008 10:50:06 AM (GMT Standard Time, UTC+00:00)  #    Comments [0]   Interview Question .NET  | 

System.Diagnostics.Process objDocProcess = new System.Diagnostics.Process();

objDocProcess.EnableRaisingEvents = false;

objDocProcess.StartInfo.FileName = @"C:\Excel.xls";

objDocProcess.Start();

Friday, August 01, 2008 9:48:11 AM (GMT Standard Time, UTC+00:00)  #    Comments [0]   Interview Question .NET  | 

A string is a sequential collection of Unicode characters that is used to represent text. At the other hand the string builder is sealed class(Cannot be inherited)it represents a mutable string of characters.

 

String is mutable that means that it can't be modified once created, to modify a given string by appending new characters or so the CLR destroy the first string instance and create a new string one and this costs in terms of memory and time process.

 

 Using the string builder, you create a mutable object that recieves modification without having to be destroyed and reinstanciated for each modifiaction

Friday, August 01, 2008 6:10:47 AM (GMT Standard Time, UTC+00:00)  #    Comments [0]   Interview Question .NET  | 
 Thursday, July 31, 2008

Poly means many and morph means form. Thus, polymorphism refers to being able to use many forms of a type without regard to the details.

Polymorphism have 2 types :

1. Compile time also called overloading have 3 types.

·         Constructor overloading (i.e., with same constructor name and different no of arguments or different datat types or both )

·         Function overloading (i.e., with same function name and different no of arguments or different data types or both)

·         operator overloading: example : Variable++;

2 Run time

·         It is achieved by overriding parent class method:

Thursday, July 31, 2008 2:05:28 PM (GMT Standard Time, UTC+00:00)  #    Comments [0]   Interview Question .NET  | 

1. OnInit (Init)  -- Inializes all Child controls on the Page

2. LoadControlState  -- Loads the Control State 

3. LoadViewState -- Loads the View State

4. LoadPostData -- Control properties are set according to the received form data

5. Load -- Actions can be performed on the controls as all the pre-activities are complete by this time

6. RaisePostDataChangedEvent -- This event is raised if data has been changed in previous and Current Postbacks.

7. RaisePostBackEvent -- This event handles the user action that caused the Postback.

8. PreRender (OnPreRender) -- This event takes place between postback and saving viewstate. Till this stage changes will be saved to the control.

9. SaveControlState -- Self Explanatory

10. SaveViewState -- Self Explanatory

11. Render -- Generates artifacts at Client side (HTML,DHTML,Scripts) to properly display controls

12. Dispose -- Releases unmanaged Resource ( Database connections, file handles)

13. Unload -- Releases managed Resources ( Instances created by CLR)

Thursday, July 31, 2008 1:47:47 PM (GMT Standard Time, UTC+00:00)  #    Comments [0]   Interview Question ASP.NET  | 

The XmlSerializer can be used when you need the data in the object to be stored in an XML Format. However, this serialize has the limitation that it can serialize only the public fields of an object.

The SoapFormatter is ideal in scenarios where you need interoperability. This is ideal in applications spanning heterogeneous environments.

The BinaryFormatter generates a very compact stream when an object is serialized as compared to the other two techniques and hence is useful when data needs to travel electronically across the wire. This is appropriate when the applications do not involve heterogeneous environments.

Thursday, July 31, 2008 1:43:06 PM (GMT Standard Time, UTC+00:00)  #    Comments [0]   Interview Question .NET  | 

Serialization is the process of saving the state of an object by converting it to a stream of bytes. The object can then be persisted to file, database, or even memory. The reverse process of serialization is known as deserialization

 

This classification arises from the format in which the data in the object is persisted. Each of the serialization techniques mentioned have different capabilities and each excel in specific scenarios. The XML serialization technique can convert only the public properties and fields of an object into an XML format. The XML serialization is also known as shallow serialization.

This inability of the XMLSerializer to serialize the private fields of an object is overcome by the SOAP and binary serialization techniques. In the binary and SOAP serialization techniques, the state of the entire object is serialized into a stream of bytes. In cases where the object contains a reference to other objects, even those are serialized. This type of serialization is known as deep serialization.

Thursday, July 31, 2008 1:40:04 PM (GMT Standard Time, UTC+00:00)  #    Comments [0]   Interview Question .NET  | 
  • An abstract class may contain complete or incomplete methods. Interfaces can contain only the signature of a method but no body. Thus an abstract class can implement methods but an interface can not implement methods.

 

  • An abstract class can contain fields, constructors, or destructors and implement properties. An interface can not contain fields, constructors, or destructors and it has only the property's signature but no implementation.

 

  • An abstract class cannot support multiple inheritances, but an interface can support multiple inheritances. Thus a class may inherit several interfaces but only one abstract class.

 

  • A class implementing an interface has to implement all the methods of the interface, but the same is not required in the case of an abstract Class.

 

  • Various access modifiers such as abstract, protected, internal, public, virtual, etc. are useful in abstract Classes but not in interfaces.
Thursday, July 31, 2008 12:28:18 PM (GMT Standard Time, UTC+00:00)  #    Comments [0]   Interview Question .NET  | 
 Tuesday, July 01, 2008

You bet. Just call SetNoStore on the HttpCachePolicy object exposed through the Response object's Cache property, as demonstrated here:

 

 

<%@ Page Language="C#" %>
<html>
<body>
<%
Response.Cache.SetNoStore ();
Response.Write (DateTime.Now.ToLongTimeString ());
%>
</body>
</
html>

 

 

SetNoStore works by returning a Cache-Control: private, no-store header in the HTTP response. In this example, it prevents caching of a Web page that shows the current time.

Tuesday, July 01, 2008 11:24:24 AM (GMT Standard Time, UTC+00:00)  #    Comments [0]   Interview Question ASP.NET  | 

Most browsers recognize the following META tag as a signal to automatically refresh the page every nn seconds:

 

<meta http-equiv="Refresh" content="nn">

Here's an ASPX file that displays the current time of day. Once displayed, it automatically refreshes every 5 seconds:

 

<% Page Language="C#" %>
<meta http-equiv="Refresh" content="5">
<
html>
<body>
<%
Response.Write (DateTime.Now.ToLongTimeString ());
%>
</body>
</
html>

Tuesday, July 01, 2008 11:08:25 AM (GMT Standard Time, UTC+00:00)  #    Comments [0]   Interview Question ASP.NET  | 

Use the HtmlInputFile class, which you can declare an instance of with an <input type="file" runat="server"/> tag. The following example is a complete ASPX file that lets a user upload an image file and a comment descibing the image. The Upload_Click method writes the image and the comment to a table named Pictures in a SQL Server database named MyPictures.

<form id="Form2" enctype="multipart/form-data" runat="server">
<table>
<tr>
<td>File name</td>
<td><input type="file" id="Upload" runat="server" /></td>
</tr>
<tr>
<td>Comment</td>
<td><asp:TextBox ID="Comment" RunAt="server" /></td>
</tr>
<tr>
<td></td>
<td><asp:Button Text="Upload" OnClick="Upload_Click(" RunAt="server" /></td>
</tr>
</table>
</
form>

protected void Upload_Click(object sender, EventArgs e)
{
// Create a byte[] from the input file

int len = Upload.PostedFile.ContentLength;

byte[] pic = new byte[len];

Upload.PostedFile.InputStream.Read(pic, 0, len);

// Insert the image and comment into the database

SqlConnection connection = new SqlConnection("server=localhost;database=mypictures;uid=sa;pwd=");

try

{

connection.Open();

SqlCommand cmd = new SqlCommand("insert into Pictures " + "(Picture, Comment) values (@pic, @text)", connection);

cmd.Parameters.Add("@pic", pic);

cmd.Parameters.Add("@text", Comment.Text);

cmd.ExecuteNonQuery();

}

finally{
connection.Close();
}
}

Tuesday, July 01, 2008 11:02:22 AM (GMT Standard Time, UTC+00:00)  #    Comments [0]   Interview Question ASP.NET  | 
Copyright © 2009 Software Code Help. All rights reserved.
DasBlog 'Portal' theme by Johnny Hughes.
Pick a theme: