Thursday, August 10, 2006
FREE tranining CDshttp://www.appdev.com/promo/freecd.asp?PC=SN00031 titles include.. Visual Studio 2005
Visual Studio .NET
Microsoft BizTalk Server 2006
Microsoft SQL Server 2005 NEW!
Microsoft SQL Server 2000
Microsoft Certification
Friday, July 28, 2006 ASP.NET page eventsThe page events fire in the following sequesnce Init, Load, PreReneder,Unloadvoid Page_Init(Object o,EventArgs e) void Page_Load(Object o,EventArgs e) void Page_PreRender(Object o,EventArgs e) void Page_Unload (Object sender , EventArgs e) Sunday, July 02, 2006 How to use COM objects if not using Visual Studio.NETIf you are not using the Visual Studio .NET IDE; use Windows Forms ActiveX Control Importer (Aximp.exe) to convert type definitions in a COM type library for an ActiveX control into a Windows Forms control.For instance: to generate the interop DLL's for the ActiveX browser component using the command line run aximp ..\system32\shdocvw.dll relative to your system32 path. Compilation of a form that uses the AxSHDocVw.AxWebBrowser class would be as follows: csc /r:SHDocVw.dll,AxSHDocVw.dll YourForm.cs. Credits:Alexander Kent Wednesday, March 29, 2006 SDKcsc.exe /t:library MathLib.cs The C# compiler will produce a library assembly called MathLib.DLL -- Remember that an assembly consists of language-independent IL code. It is thus possible to inherit and extend the C# class in VB.NET -- From VS.NET Cmd prmtSN.EXE –k MathLib.snk This line of code instructs SN.EXE to store a globally unique private key into a file called MathLib.snk You can either specify a private key file that you generate explicitly using SN.EXE, or you can let VS.NET generate one for you by clicking the Generate Key button. Assembly Verionsing: <major version>.<minor version>.<build number>.<revision> When a new version of a component is released, if its major or minor number changes, it is deemed incompatible with its predecessor. Thursday, February 09, 2006 Global Assembly CacheIf you are COM buff, you know that ‘regsvr32’ is a history in .NET. What does it mean? In COM, all the .dlls are registered in the registry with ‘regsvr32’ command. Once a dll is registered by this way, it can be accessed from any application running locally. Well, that was great achievement in COM days as one copy of the dll serves the need of multiple applications. Reusability, scalability were the buzz words. Say, you have 5 applications hosted on your web server, all of them send out emails. So, the code that parses the contents like to, subject, text of the email and then communicate with the SMTP server, is needed in all the 5 application. The best thing would be, put everything in a dll and do a regsvr32. Boom !!!! the dll can be accessed from all the applications. Life was good. However, maintenance was problem. After a while what if one of the applications wants a slightly different functionality.. you can go with a brand new dll for it.. and may be a while later, another brand new for another application.. each time the underlying code in the application has to be changed to access the new dll, so, the point is it was simply not possible to have different version of same dll on the same computer… Well, then came .NET. Here different versions of the same dll can be present in the same computer. How ? Maintain a local copy of the dll in the project bin folder. You don’t have to register globally. Each project will look into the local bin folder. OK. What if there is a need to have a machine wide copy .. say for example drivers that connect to SQL server.. well GAC is your buddy.. Global Assembly Cache. Works same as COM days. The application first looks in the bin folder and then if it doesn’t find the dll, then it looks in the GAC. Here is how you can use GAC. · Use Windows Explorer to drag assemblies into the cache (C:\WINNT\assembly) Assemblies deployed in the global assembly cache must have a strong name. A strong name consists of the assembly's identity — its simple text name, version number, and culture information (if provided) — plus a public key and a digital signature. More on Strong Name Note Assemblies placed in the global assembly cache must have the same assembly name and file name (not including the file name extension). For example, an assembly with the assembly name of myAssembly must have a file name of either myAssembly.exe or myAssembly.dll. Multiple copies of assemblies with the same name but different version information can be maintained in the global assembly cache. Not possible in COM. Disadvantages: In the COM and GAC, when ever you move code across servers, make sure, you register COM dlls / put assemblies in GAC. You can not use xcopy if GAC is used in your application. Friday, January 27, 2006 RemotingSystem.Runtime.Remoting.ObjectHandle objRemote; objRemote = System.Activator.CreateInstance(assemblyName, className); object objCurr = objRemote.Unwrap(); int test = objCurr.Sum(1,2) http request to another webpageSystem.Net.HttpWebResponse Rs; System.Net.HttpWebRequest Rq; Rq = (HttpWebRequest)WebRequest.Create(url); Rq.Method = "GET"; Rq.ContentType = "text/html"; Rq.Proxy.Credentials = CredentialCache.DefaultCredentials; Rq.Credentials = CredentialCache.DefaultCredentials; Rq.ServicePoint.ConnectionLimit = 25; Rs = (HttpWebResponse)Rq.GetResponse(); StreamReader sr= new StreamReader(Rs.GetResponseStream()); String html = sr.ReadToEnd(); Wednesday, January 11, 2006 SQL Connection/////////// using System.Data; using System.Data.SqlClient; /////////// SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["connectionString"]); SqlCommand myCommand = new SqlCommand("sp_UpdateUser", myConnection); myCommand.CommandType = CommandType.StoredProcedure; SqlParameter parameterItemID = new SqlParameter("@ItemID", SqlDbType.Int, 4); parameterItemID.Value = itemId; myCommand.Parameters.Add(parameterItemID); // out parameters to Sproc SqlParameter paramRoles = new SqlParameter("@AccessRoles", SqlDbType.NVarChar, 256); paramRoles.Direction = ParameterDirection.Output; myCommand.Parameters.Add(paramRoles); myConnection.Open(); try { myCommand.ExecuteNonQuery(); //or // SqlDataReader result = myCommand.ExecuteReader(CommandBehavior.CloseConnection); // return result } catch{} finally { if (myConnection.State == ConnectionState.Open) { myConnection.Close(); } } |
About Me
LinksPrevious Posts
Archives |