蝈蝈俊.net

-- 用随笔来记录自己的技术感触
随笔 - 673, 评论 - 4328, 引用 - 276

导航

关于

记录自己的技术心得

标签

每月存档

最新留言

  • Bbymerhc
    Very interesting tale <a href=" http://www.wikio.com/user/isufaifameu/bio "...
    by Bbymerhc(匿名) on 2010/3/19 16:51:18
  • Fhpjpshb
    Very funny pictures <a href=" http://www.wikio.com/user/hupofugomia/bio "&a...
    by Fhpjpshb(匿名) on 2010/3/19 16:16:20
  • Wgugqqku
    Very Good Site <a href=" http://www.wikio.com/user/hupofugomia/bio "&gt...
    by Wgugqqku(匿名) on 2010/3/19 15:22:56
  • Mtrpkxnr
    <a href=" http://www.wikio.com/user/lyepylatytof/bio ">sex free lol...
    by Mtrpkxnr(匿名) on 2010/3/19 14:47:56
  • Kshngzfl
    It's funny goodluck <a href=" http://www.wikio.com/user/lyepylatytof/bio "&...
    by Kshngzfl(匿名) on 2010/3/19 13:51:32
  • Whaxznox
    this post is fantastic <a href=" http://www.wikio.com/user/biukyera/bio "&a...
    by Whaxznox(匿名) on 2010/3/19 13:16:55
  • Bhtmssbu
    Excellent work, Nice Design <a href=" http://www.wikio.com/user/biukyera/bio &qu...
    by Bhtmssbu(匿名) on 2010/3/19 12:21:10
  • Qznunxlt
    I love this site <a href=" http://www.wikio.com/user/sonomureper/bio "&...
    by Qznunxlt(匿名) on 2010/3/19 11:47:59
  • Dfczuaqj
    Jonny was here <a href=" http://www.wikio.com/user/sonomureper/bio "&gt...
    by Dfczuaqj(匿名) on 2010/3/19 10:52:34
  • re:动画缓冲或叫缓动函数(Animation Easing)
    <p><a href="http://www.moretiffany.com/">tiffany jewelry</a> Choose, buy...
    by sibat0705(注册) on 2010/3/19 10:31:15

广告

使用企业库在某些站点会报试图执行安全策略不允许的操作异常的解决方法。

我们在WEB站点使用企业库的时候,有时候会有如下的异常产生:

安全性异常
说明: 应用程序试图执行安全策略不允许的操作。要授予此应用程序所需的权限,请与系统管理员联系,或在配置文件中更改该应用程序的信任级别。

异常详细信息: System.Security.SecurityException: 不允许所请求的注册表访问权。

堆栈跟踪:

[SecurityException: 不允许所请求的注册表访问权。]
   Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable) +473
   System.Diagnostics.EventLog.CreateEventSource(String source, String logName, String machineName, Boolean useMutex) +443
   System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData) +347
   System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType type, Int32 eventID, Int16 category) +21
........  

Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.PerformanceCounterInstances..ctor(String categoryName, String counterName, Boolean createNewInstance)
Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.InstrumentedEvent.AddPerformanceCounter(String category, String[] counterNames, Boolean createNewInstance)   Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.InstrumentedEvent.Initialize(String counterCategory, String[] counterNames, Boolean createNewInstance, String eventLogSource, EventLogIdentifier[] eventIds)

        造成这个的原因是企业库的公共项目中:Instrumentation 目录下有操作日志、性能的代码。而这些代码需要一定的权限才可以执行。

解决方案:
1、去掉这些代码。(这会是一个痛苦的经历,代码割舍不清呀)
2、给IUSR 帐户访问注册表的权限(安全问题呀!)
我们当然不推荐这2个做法:

我们推荐的做法:重新编译 Microsoft.Practices.EnterpriseLibrary.Common 项目,编译时把其中 Conditional Compilation Constants 设置中除 DEBUG;TRACE 外的其他项都去掉。

具体步骤请参看:
http://dotnetjunkies.com/WebLog/sskokku/archive/2005/03/25/61376.aspx

附图:

如何修改企业库公共项目的生成配置 

posted on 2005-07-26 17:03:00 by ghj1976  评论(11) 阅读(13034)

项目调试时候,出现其中用到的一个组件“访问被拒绝”的解决方法。

有时候,我们在调试ASP.net程序的时候,会很痛苦的碰到。某某组件访问被拒绝。这时候重起IIS,电脑注销都不起作用。这时候的错误信息一般类似如下的方式:

“/”应用程序中的服务器错误。
--------------------------------------------------------------------------------
配置错误
说明: 在处理向该请求提供服务所需的配置文件时出错。请检查下面的特定错误详细信息并适当地修改配置文件。
分析器错误信息: 访问被拒绝:“CSDN.Authentication”。
源错误:
行 196:    <add assembly="System.EnterpriseServices, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
行 197:    <add assembly="System.Web.Mobile, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
行 198:    <add assembly="*"/>
行 199:   </assemblies>
行 200:  </compilation>

源文件: c:\windows\microsoft.net\framework\v1.1.4322\Config\machine.config    行: 198
程序集加载跟踪: 下列信息有助于确定程序集“CSDN.Authentication”无法加载的原因。
=== Pre-bind state information ===
LOG: DisplayName = CSDN.Authentication
 (Partial)
LOG: Appbase = file:///F:/MyDevelop/AD/Code/ADManageWeb
LOG: Initial PrivatePath = bin
Calling assembly : (Unknown).
===
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Post-policy reference: CSDN.Authentication
LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET Files/root/3151f96f/581ce000/CSDN.Authentication.DLL.
LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET Files/root/3151f96f/581ce000/CSDN.Authentication/CSDN.Authentication.DLL.
LOG: Attempting download of new URL file:///F:/MyDevelop/AD/Code/ADManageWeb/bin/CSDN.Authentication.DLL.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Post-policy reference: CSDN.Authentication, Version=1.0.1965.30523, Culture=neutral, PublicKeyToken=null
--------------------------------------------------------------------------------
版本信息: Microsoft .NET Framework 版本:1.1.4322.2300; ASP.NET 版本:1.1.4322.2300

其中最常见的原因是Indexing service服务引起的。解决方法就是停用Indexing service,或配置ASP.net 的临时目录不受Indexing service服务的影响。

配置ASP.net 的临时目录不受Indexing service服务的影响的步骤如下:

1、开始 -- 管理工具 -- 计算机管理(Win2003的位置,其他操作系统类似)打开计算机管理
2、展开计算机管理左边树中“服务和应用程序”节点,再在其下展开“索引服务”节点,再在其下展开“System”节点,再在其下展开“目录”节点。
3、在计算机管理的右边我们可以看到配置的索引服务目录。
4、在“目录”节点上右击鼠标,选择“新建”--“目录”
5、在“添加目录”对话框中,路经输入框中输入 ASP.net 的临时文件目录。默认应该是:
c:\<WINDIR>\Microsoft.NET\Framework\<Version Number>\Temporary ASP.NET Files  目录。
<Version Number> 指你要处理的.net版本。
6、在“包含在索引中吗?”选项中,选择“否”
7、单击“确定”按钮
8、在“索引服务”节点上右键单击,重起索引服务即可。

参考以下文档:
http://community.csdn.net/Expert/topic/4075/4075120.xml
http://support.microsoft.com/default.aspx?scid=kb;en-us;329065

posted on 2005-07-05 14:35:00 by ghj1976  评论(38) 阅读(12558)

派生类无法作为ref参数

首先我们来看一段代码:

using System; class Class1 { static void Main(string[] args){ DeriveClass d = new DeriveClass(); Do(ref d); } public static void Do(ref BaseClass b){} } class BaseClass {} class DeriveClass : BaseClass {}


这段代码我们在编译的时候,会产生如下异常:

F:\MyDevelop\Tests\ConsoleApplication2\Class1.cs(8): 与“Class1.Do(ref BaseClass)”最匹配的重载方法

具有一些无效参数
F:\MyDevelop\Tests\ConsoleApplication2\Class1.cs(8): 参数“1” : 无法从“ref DeriveClass”转换为“ref BaseClass”

我们先来看解决方法,先不分析原因:
几种解决方法如下:

解决方法一,在传递前,先把派生类转换为基类

using System; class Class1{ static void Main(string[] args){ DeriveClass d = new DeriveClass(); BaseClass b = d; Do(ref b); } public static void Do(ref BaseClass b){} } class BaseClass {} class DeriveClass : BaseClass {}


解决方法二:不使用ref参数。

using System; class Class1{ static void Main(string[] args) { DeriveClass d = new DeriveClass(); Do(d); } public static void Do(BaseClass b) {} } class BaseClass {} class DeriveClass : BaseClass {}

分析原因(个人分析):
如果要使用ref向一个函数传递进入一个类,我们就可以在这个函数体内,new 一个新的对象,这个参数出来函数体后,仍然被指向那个新的对象。

如果最初的代码可以编译通过的话,就会产生一种情况:
一个派生类的指针被传递进入函数,函数体内用户new 了一个基类,并把上述原来指向派生类的指针指向一个基类。这时候,在外部函数体后面的代码,可能就会出问题。为了避免这个问题,编译器就不让你编译通过最上面的代码。

当然你可以通过解决方法一的方式,欺骗编译器。以编译通过。但是这时候,一定要小心出现上述说的:指向派生类的指针指向一个基类带来的问题。

posted on 2005-07-01 10:40:00 by ghj1976  评论(12) 阅读(2893)

Powered by: Joycode.MVC引擎 0.5.2.0