.NET Software Development Stack: ASP.NET, WPF, WinForms, ADO.NET, Entity Framework, SQL, Design Patterns
Friday, June 27, 2008
WPF Beginners Guide
WPF: A Beginner's Guide - Part 1 of n
WPF: A Beginner's Guide - Part 2 of n
WPF: A Beginner's Guide - Part 3 of n
WPF: A Beginner's Guide - Part 4 of n
WPF: A Beginner's Guide - Part 5 of n
WPF: A Beginner's Guide - Part 6 of n
I hope this will greatly help many of you and you'll get main concepts and basics of this wonderful technology. Here is his blog: Sacha Barber blog
VS 2005 Error 1: "Could not load type..."
You can receive this error "Could not load type" error message in your ASP.NET Application, when you browse to .aspx page by using Visual C# .NET or running from local IIS.
SYMPTOMS
When you browse to an .aspx page, you may receive one of the following error messages:
Could not load type 'Namespace.Global'.
-or-
Could not load type 'Namespace.PageName'.
CAUSE
These errors occur if the .aspx page or the Global.asax page contains a reference to a code-behind module and if the application has not been built.
RESOLUTION
Use one of the following methods to build the application:
• Use the C# command line compiler (CSC.exe) to run the following command:
csc /t:library /r:System.web.dll /out:mydll.dll myfile.cs
• In Microsoft Visual Studio .NET, click Build on the Build menu.
NOTE: Microsoft Visual Basic .NET background compiles the project as soon as it is created. Because Visual C# .NET projects only background parse, you must explicitly build the application.
Steps to Reproduce the Behavior
1. Start Visual Studio .NET.
2. On the File menu, point to New, and then click Project.
3. Click Visual C# Projects under Project Types, and then click ASP.NET Web Application under Templates.
4. Right-click WebForm1.aspx, and then click View in Browser.
Materials are taken from http://support.microsoft.com/kb/306155
Wednesday, June 25, 2008
SQL Error "INSERT Failed" When You Update Table Referenced in an Indexed View
When you run a stored procedure or SQL INSERT statement directly, which attempts to insert a row into a table that is referenced in an indexed view, the following error may occur:
INSERT failed because the following SET options have incorrect settings: 'ARITHABORT' Furthermore, this error may occur even if "SET ARITHABORT ON" is included in the batch or stored procedure that attempts the INSERT.
CAUSE
To successfully insert a row into a table that is referenced in an indexed view, the SQL ARITHABORT configuration setting must be set to ON. Furthermore, the statement that applies this configuration setting must be executed in its own batch. Because stored procedures contain only one batch, adding the statement to the procedure does not work.
MY SOLUTION
My own solution was to rebuild stored procedures and indexed used with the table you are updating.
RESOLUTION
To resolve this problem, add the following ADO code to your application after you open the connection to your database: MyConnection.Execute "SET ARITHABORT ON"
where MyConnection is a reference to the ADO connection object you are using to run the stored procedure that performs an INSERT or the SQL INSERT statement.
Material taken from: http://support.microsoft.com/kb/305333
Tuesday, June 17, 2008
Sunday, June 1, 2008
HTTP pipeline in ASP.NET 2.0.
Today I will provide you with a short reference for the steps in HTTP pipeline in ASP.NET 2.0. Some of the steps are internal and can't be subscribed by HTTP modules or global.asax:
1. Internal step to validate request. Protects against malicious attacks exploiting path canonicalization
2. Internal step to perform URL mapping (if the URL mapping feature is enabled)
3. Fire BeginRequest event
4. Fire AuthenticateRequest event
5. Fire DefaultAuthentication internal event
6. Fire PostAuthenticateRequest event
7. Fire AuthorizeRequest event
8. Fire PostAuthorizeRequest event
9. Fire ResolveRequestCache event
10. Fire PostResolveRequestCache event
11. Internal step to determine the IHttpHandler to process the current request (this is when the page compilation takes place)
12. Fire PostMapRequestHandler event
13. Fire AcquireRequestState event
14. Fire PostAcquireRequestState event
15. Fire PreRequestHandlerExecute event
16. Internal step to execute the IHttpHandler (call its ProcessRequest method) for the current request. The handler is determined at step #11
17. Fire PostRequestHandlerExecute event
18. Fire ReleaseRequestState event
19. Fire PostReleaseRequestState event
20. Internal step to perform response filtering (only if HttpResponse.Filter is installed)
21. Fire UpdateRequestCache event
22. Fire PostUpdateRequestCache event
23. Fire EndRequest event. This is the only event that is guaranteed to be fired for each request
I've found this info in Dmitryr's blog and took it from another topic, but this info will be valuable also.
Monday, May 26, 2008
ASP.NET 2.0 Directives
Hi,
Today I've decided to write about ASP.NET 2.0 directives. There are 11 of them. Here is a full list of directives:
Directive | Attributes | Short description |
@Assembly | Name Src | Imports assembly with given name into page or control |
@Control | The same as Page has | Applied for properties setting while creating custom controls |
@Implements | Interface | Specifies that page's class implements this interface |
@Import | Namespace | Imports given namespace |
@Master | The same as Page has | Apllied for specifying Master Page template. New in ASP.NET 2.0 |
@MasterType | TypeName VirtualPath | Gives strongly typed reference on class contained in Master Page. Gives opportunity to reference class properties. |
OutputCache | Duration Location VaryByCustom VaryByHeader VaryByParam VaryByControl | Controls Page or Control caching. See msdn for details. |
@Page | Described below | Attributes refering current Page.Used only if files with .aspx extension. |
@PreviousPageType | TypeName VirtualPath | Page, which was used for user data sending. New in ASP.NET 2.0. |
@Reference | Page Control | Page or Control that should be compiled with current. |
@Register | Assembly Namespace Src TagName TagPrefix | Associates aliases with namespaces and class names for notation in custom server control syntax. |
@Page Directive
The @Page directive enables you to specify attributes and values for an Asp.Net Page to be used when the page is parsed and compiled. Every .aspx files should include this @Page directive to execute. There are many attributes belong to this directive. We shall discuss some of the important attributes here.
Language: This attribute tells the compiler about the language being used in the code-behind. Values can represent any .NET-supported language, including VB.NET, C#, or JScript .NET.
AutoEventWireup: For every page there is an automatic way to bind the events to methods in the same .aspx file or in code behind. The default value is true.
CodeFile: Specifies the code-behid file with which the page is associated.
Title: To set the page title other than what is specified in the master page.
Culture: Specifies the culture setting of the page. If you set to auto, enables the page to automatically detect the culture required for the page.
UICulture: Specifies the UI culture setting to use for the page. Supports any valid UI culture value.
ValidateRequest: Indicates whether request validation should occur. If set to true, request validation checks all input data against a hard-coded list of potentially dangerous values. If a match occurs, an HttpRequestValidationException Class is thrown. The default is true. This feature is enabled in the machine configuration file (Machine.config). You can disable it in your application configuration file (Web.config) or on the page by setting this attribute to false.
Theme: To specify the theme for the page. This is a new feature available in Asp.Net 2.0.
SmartNavigation: Indicates the smart navigation feature of the page. When set to True, this returns the postback to current position of the page. The default value is false.
MasterPageFile: Specify the location of the MasterPage file to be used with the current Asp.Net page.
EnableViewState: Indicates whether view state is maintained across page requests. true if view state is maintained; otherwise, false. The default is true.
ErrorPage: Specifies a target URL for redirection if an unhandled page exception occurs.
Inherits: Specifies a code-behind class for the page to inherit. This can be any class derived from the Page class.
There are also other attributes which are of seldom use such as Buffer, CodePage, ClassName, EnableSessionState, Debug, Description, EnableTheming, EnableViewStateMac, TraceMode, WarningLevel, etc. Here is an example of how a @Page directive looks
Monday, May 5, 2008
How to disable Vista UAC.
I've noticed that Vista UAC turned on automatically about 2 weeks(my work PC is in domain) ago and now I can't turn it off using Control Panel - it simply doesn't turns off. UAC irritates me highly and I've started searching the solution how to kill it :) And found one very usefull. UAC still works but doesn't display any messages :-))
You just need to create 2 keys in registry, here they are:
In [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System]
"ConsentPromptBehaviorAdmin"=dword:00000000
"EnableLUA"=dword:00000001
Or if you want to turn it off totally simply change and reboot:
"EnableLUA"=dword:00000000
You can also use msconfig to do the same:
- Start - Run - msconfig - Tools -Disable UAC
Hope this will help other people.