Category: C# 編碼原則

if you get this error, it’s because Sliverlight assembly is not in GAC. Do this to fix:

cd C:\Program Files\Microsoft Silverlight\4.0.50524.0
gacutil -i System.Core.dll
gacutil -i system.dll
gacutil -i
gacutil -i system.xml.dll
gacutil -i System.Runtime.Serialization.dll

check out what other people said.


If you get something like this:

Server Error in '/applicationname' Application.
Security Exception
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

Exception Details: System.Security.SecurityException: Requested registry access is not allowed.

Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:
[SecurityException: Requested registry access is not allowed.]
Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable) +473

I’m not sure there’s a secured way, but adding permission for iis daemon user solve the problem for me.

1. Find out which deamon user your app is using, by looking up App_Pool and secruity section in event log.

2. Give the user permission to read/write access for the eventlog registry entry. To do so, open regedit and navigate to the key:


Right click and select Permissions, and add permission for the user.

3. restart iis and give it a try.

Mastering the VI editor basic –
Download PDF version here

Check out this SlideShare Presentation:

check out my main site at




想要讓開發出來的程式碼穩固且容易維護,除了有必要適當地採用設計模式 (Design Patterns) 之外,也有必要採用編碼原則 (Coding Guidelines),做為寫程式時依循的準則。設計模式是在設計階段進行的,主要由系統設計者 (System Designer)負責,所以和程式員的關係比較不是那麼密切。至於編碼方針,就和程式員的關係相當密切了。


在Google搜尋keyword :: “Code formatter, code beautifier",你可找到一票自動化的輔助工具。對C#來說,最重要的編程方針是美國微軟MSDN網站上的Design Guidelines for Class Library DevelopersreSharper則是目前我們使用的自動化工具。