Thursday, November 30, 2006

Community Credit topper...

One among the top 10 in September 2005

One among the top 10 in November 2005
One among the top 10 in October 2005
One among the top 10 in December 2005
One among the top 10 in March 2005
One among the top 10 in February 2005


http://www.community-credit.com/



Wednesday, November 29, 2006

'Microsoft.VisualStudio.Tools.Applications.Adapter, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

Error 1 Assembly 'Microsoft.VisualStudio.Tools.Applications.Adapter, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' uses 'Microsoft.VisualStudio.Tools.Applications.Contract, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' which has a higher version than referenced assembly 'Microsoft.VisualStudio.Tools.Applications.Contract, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' c:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.Tools.Applications.Adapter.dll Test



When i got this error i tried to uninstall the Visual Studio 2005 SDK Feb release from my system. Now the problem get solved.



For more check out these articles.
http://msdn2.microsoft.com/en-us/library/zdc263t0.aspx
http://www.summsoft.com/blogs/garyvsta/default.aspx

Saturday, November 18, 2006

New Technology discussion group in MSN - Join Now

Here is one of the best interactive community for All Technologies. All technology lovers and programmers come lets add power to your technical skill.

Join Now

http://groups.msn.com/DevelopersParadise

Thursday, November 16, 2006

Unsafe Code in C#

Unsafe code is formally denoted as unmanaged code .NET. Unmanaged codes as the possibility to use the pointers in the .NET managed code. Basically .NET hides most of the memory management; it makes all the .NET programmer and developers easier for development. Commonly there is need to use the unsafe code in our application while using Microsoft .NET.

When and why should we need this unsafe or unmanaged code in .NET? The answer is if you want to access memory mapped devices or if you want to create an application that to interface with your operation system, while using pointer to increase your application performance, External functions, in some cases you might need to write an application that analyzes another application process and memory etc, we need this unmanaged code, it will be more advantageous when we use this in those situations.

Some of the main advantages about the unsafe code in .NET are performance and flexibility, compatibility like DLLImport, memory addresses.

Some of the notable disadvantages about the unmanaged code in .NET are Complex to implement in C#, you should be more careful while using pointers in .NET application, miss use of pointer will cause many problems like stack overflow, overwrite existing or other variables, unauthorized access to memory areas, simple mistake in using pointers might lead your application to crash randomly and unpredictably, using pointers will cause the code to fail in the .net type-safety checks.

Sample unmanaged code snippet:

DllImport("shell32.dll", SetLastError = true)]
extern public static bool
ShellExecuteEx(ref ShellExecuteInfo lpExecInfo);
public const uint SW_NORMAL = 1;
static void OpenAs(string file)
{
ShellExecuteInfo sei = new ShellExecuteInfo();
sei.Size = Marshal.SizeOf(sei);
sei.Verb = "openas";
sei.File = file;
sei.Show = SW_NORMAL;
if (!ShellExecuteEx(ref sei))
throw new System.ComponentModel.Win32Exception();
}


For more reference

Sunday, November 12, 2006

Show/Hide a row in ASP.NET DataGrid

In this article i'm goin to explain you how to show or hide a certain row in the ASP.NET datagrid using JavaScript. First populate your datagrid with some records. Here in this example i have populated my datagrid with one sample XML file.

Sample XML document structure:

<movies>

<movie movieid="1000">

<moviename>Dr.No</moviename>
<artist>James Bond</artist>
<year>1970</year>
<language>English</language> <image>anne_hathaway90x80.jpg</image>
</movie>
<movie movieid="1001">
<moviename>Raja</moviename>
<artist>Raja</artist>
<year>1990</year>
<language>Hindi</language> <image>dogsfri90x80.jpg</image>
</movie>
</movies>

After populating the grid, my grid shows like this...



The following code part is used for populating my datagrid in my ASP.NET page. autoGenerateColumns is set to False in order to manipulate the columns manually.

string SampleDataToPopulate = Server.MapPath("sampledatafile.xml");
DataSet dataSet = new DataSet();
dataSet.ReadXml(SampleDataToPopulate);
dgShowHide.DataSource = dataSet;
dgShowHide.DataBind();

and with DataBinder.Eval in the ItemTemplate of the datagrid, i'm populating my data.


JavaScript to do Show/Hide in ASP.NET Datagrid:

The javascript function loops through the arguments and sets up an element object to change the visibility to hidden or visible for the datagrid table row.

JavaScript Fuction:

function chgTextDetails(link)
{
link += "link";
linkText = document.getElementById(link);
linkText.firstChild.nodeValue;
if (linkText.firstChild.nodeValue == "Hide")
{
linkText.firstChild.nodeValue = "Show";
}
else
{
linkText.firstChild.nodeValue = "Hide";
}
}

After implementing all these part of code and we will get the complete solution for show hide operation in the ASP.NET Datagrid. After implementing the grid looks like. The screen clips as follows.


Here is the completed and running solution is aatached. Download The SourceCode

Saturday, November 11, 2006

C# to VB.NET and VB.NET to C#

Some important and usefull links for .NET programmers. Here in this blog you can get some of the usefull C# to VB.NET and VB.NET C# online code conversion websites.

C# to VB.NET Links:

http://www.kamalpatel.net/ConvertCSharp2VB.aspx

VB.NET to C# Links:

http://www.carlosag.net/Tools/CodeTranslator/Default.aspx

http://www.developerfusion.co.uk/utilities/convertvbtocsharp.aspx

Tuesday, November 07, 2006

"LoaderLock was detected" Error when debugging my .NET DirectX code sample:

When tried to develop a video player in .NET 2.0 and Visual Studio 2005 Team Suite using DirectX SDK I was stuck with this error. I tried the same code in .NET1.1 and Visual Studio 2003, the code runs fine, no "LoaderLock was detected" error. Then I started exploring about the error I got while using Visual Studio 2005.

Check this original error message:

LoaderLock was detected
DLL 'C:\WINDOWS\assembly\GAC\Microsoft.DirectX\1.0.2902.0__31bf3856ad364e35\Microsoft.DirectX.dll' is attempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang.

Managed Debugging Assistants is also referred as MDA, MDA work with the Common Language Runtime (CLR) to provide information on runtime state. They generate information about runtime events. Load Lock is one of the MDA available in .NET framwork, the code part which exist in all Managed DirectX 1.1 assemblies, is the reason to MDA firing. The most common failure when executing code inside the operating system's loader lock is that threads will deadlock when attempting to call other Win32 functions that also require the loader lock.

The only thing that seems to hold this situation is simply to turn off the MDA for LoaderLock, which is not recommended solution.

Global registry key which is used to turn on/off MDA.

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework]
"MDA"="1"

Better options to work around this problem are...

Look at the stack trace for the thread that has activated this MDA. The thread is attempting to illegally call into managed code while holding the operating system's loader lock. You will probably see a DLL's DllMain or equivalent entry point on the stack. The operating system's rules for what you can legally do from inside such an entry point are quite limited. These rules preclude any managed execution.

To go back to Visual Studio 2003 and .NET 1.1 . Else disable the loader lock Managed Debugging Assistants. Debug/Exceptions, Open the Managed Debugging Assistants tree node and uncheck Loader Lock. This setting is per solution so it will only affect this solution.

Tips:

In VS2005, go to the Debug->Exceptions menu. Within the Exceptions dialog expand the "Managed Debugging Assistants" node. Look for LoaderLock and uncheck the "Thrown" column.
Note: Do not disable all MDAs by setting MDA="0" in the registry as it causes problems.

Mixed managed/unmanaged C++ assemblies built for .NET Framework versions 1.0 or 1.1 generally attempt to execute managed code inside the loader lock unless special care has been taken. .NET 1.1 Managed DirectX assemblies when used with Visual Studio 2005 and .Net 2.0.

Learn About MDA:

Diagnosing Errors with Managed Debugging Assistants

Microsoft Helps related to this problem:

Managed Debug Assistants (MDAs) are cool.

Microsoft Visual Studio 2005 to debug a Microsoft Foundation Classes (MFC) class library application

Mixed DLL Loading Problem

Sunday, November 05, 2006

Using C#.NET play multimedia files - Using Multimedia Control Interface(MCI)

Multimedia is the best way to enhance the user interface of any application. In .NET there is many ways to play an Audio using any .NET technology supporting languages. One of the simple way to acheive is Multimedia Control Interface, shirtly we call it as MCI, wrapping high-level system components, such as Windows Media Player to play our audio files.

About Media Control Interface (MCI):

The Media Control Interface (MCI) provides standard commands for playing resource files. MCI's standard commands are a generic interface to almost all kind of multimedia devices. Media Control Interface provides applications with device-independent capabilities for controlling audio. MCI - High level multimedia control functions, Has commands common to all multimedia hardware. Possible since most use record/play metaphor Open a device for input or output If input, record; If output, play When done, close.

There are two different forms of MCI, one is Send command messages (like Windows messages) to MCI (need to include bit-encoded flags and C data structures) and another one is Send text strings to MCI Good for use from scripting languages with string functionality and simple to use MCI converts them to command messages.

Sending Strings to MCI:

error = mciSendString(sCmd , sRetStr, iReturn, hCallback);
· sCmd--themci command string (specifies command & device)
· sRetStr--return string buffer (NULL if none used)
· iReturn--size of return string buffer (0 if none used)
· hCallback--Handle to Callback window (NULL if none used)
– Returns 0 if command is successful, error code if not
· Can be used as a parameter to mciGetErrorString()
– Many command strings possible
– mciSendString, mciGetErrorString
– MCI Command Strings

For more details or help check the MSDN.

When Using Win32 Functions From .NET

Important note, MCI is not directly accessible from .NET, also mciSendString() is C++, not C#, but still you can use MCI and other Win32 API functions from .Net languages. The key is to use “Platform Invocation Services” “Interop Services” A generalized mechanism that allows calling functions that are imported from DLLs.

Must include: System.Runtime.InteropServices namespace; And then prefix any declarations of Win32 API functions to be used.

Example:
[DllImport("winmm.dll")]
private static extern long mciSendString(
string strCommand,
StringBuilder strReturn,
int iReturnLength,
IntPtr oCallback);


For MCI functions that DLL is winmm.dll, And then use equivalent .NET language data types for the parameters and for the type returned by the function.

Some of the disadvantages to be notes:

Code is no longer managed code and it’s no longer platform independent.

mciSendString() in .NET Unmanaged Code:

Corresponding C# parameter types would be:
– string, string, uint, intPtr
– In C# DWORD is implemented as an int

strCommand - Pointer to a null-terminated string that specifies an MCI command string.
strReturn - Pointer to a buffer that receives return information. If no return information is needed, this parameter can be null.
iReturnLength - Size, in characters, of the return buffer specified by the strReturn parameter. hwndCallback - Handle to a callback window if the "notify" flag was specified in the command string.

Some MCI Command String Commands:
· open -- initializes a multimedia device
· play– starts playing an open device
· stop -- stops playing from an open device
· record -- starts recording to a device
· seek -- move to a specified position on device
· save -- saves an MCI file
· close -- closes a device and associated resources
· set -- establish control settings for the device
· status -- returns information in 2nd parameter

However, most of these libraries are designed in such a way that they cannot be used to manipulate audio samples on the fly because they do not give you access to the actual sound data.




Here in this article i have covered some basics about the MCI in .NET. You can explore more in MSDN or in any other resource centre.

>>Download The Sample Code>>

ASP.NET MVC - Sport Facility Booking system

  The project relies on some external service providers. Thus accessing them via their API requires authentication. An API Key need to be su...