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 system.net.dll
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:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog

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

3. restart iis and give it a try.

Mastering the VI editor

http://rcm.amazon.com/e/cm?t=mingster-20&o=1&p=8&l=bpl&asins=1565924975&fc1=000000&IS2=1&lt1=_blank&m=amazon&lc1=0000FF&bc1=000000&bg1=FFFFFF&f=ifrGood basic – http://www.eng.hawaii.edu/Tutor/vi.html
Download PDF version here

Check out this SlideShare Presentation:

mingster.com

check out my main site at mingster.com

c#程式碼編寫標準

誰都會寫程式碼!幾個月的編程經驗可以讓你寫出「可運行的應用程式」。但在開發團隊的運行模式下,以最有效率的方式編碼、能被小組成員順暢承接的程式碼就必需要下更多的功夫!

要知道,大多數程式設計師在寫「可運行程式碼」,而不是「高效率程式碼」。寫高效程式碼是一項藝術,必須靠紀律及學習來實踐。建立一個高效率、有默契的開發團隊更需有一定的規範及標準流程。

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

程式碼命名及格式規範的目的為建立開發團隊的默契以及效率。檢視一篇與自己撰寫風格相同的程式碼不但能減少無謂的猜測,也能快速暸解程式碼,立即進入程式撰寫的狀況。

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