读书人

救命啊。第二发帖freetextbox在本地

发布时间: 2011-12-13 21:22:18 作者: rapoo

救命啊。第二发帖,freetextbox在本地iis测试没有问题,一传到服务器就出错。
我的程序中有用到freetextbox版本3.1.6,
我找了好多资料,说3.1.6使用是非常简单, 只是拷贝freetextbox.dll到bin下,引用,添加控件,拖过去用就可以了,没有设置其他东西。发布网站后,在本地iis测试没有问题。但是一传到服务器就老说freetextbox没有正确安装g。我快崩溃了啊。。。搞了整整两天。。。改来改去都不行啊。。

FreeTextBox has not been correctly installed. To install FreeTextBox either:
(1) add a reference to FtbWebResource.axd in web.config:
<system.web>
<httpHandlers>
<add verb= "GET "
path= "FtbWebResource.axd "
type= "FreeTextBoxControls.AssemblyResourceHandler, FreeTextBox " />
</httpHandlers>
</system.web>

(2) Save the FreeTextBox image and javascript files to a location on your website and set up FreeTextBox as follows
<FTB:FreeTextBox id= "FreeTextBox1 " SupportFolder= "ftbfileslocation " JavaScriptLocation= "ExternalFile " ButtonImagesLocation= "ExternalFile " ToolbarImagesLocation= "ExternalFile " ButtonImagesLocation= "ExternalFile " runat= "server " />


[解决办法]
晕,前两天遇到同样的问题,以下是我的网上参考和自己的总结结合,关键在于服务器上的考虑安全问题web.config被锁定了,许多dll文件不能引用,后来我换了js编辑器才解决
在 asp.net 2.0中应用 FreeTextBox就报错

Invalid ToolbarLayout -> System.Security.VerificationException: 操作可能会破坏运行时稳定性。
在 FreeTextBoxControls.ToolbarGenerator.ToolbarItemFromString(String StringName)
在 FreeTextBoxControls.ToolbarGenerator.ToolbarsFromString(String toolbarLayout)
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.Exception: Invalid ToolbarLayout -> System.Security.VerificationException: 操作可能会破坏运行时稳定性。
在 FreeTextBoxControls.ToolbarGenerator.ToolbarItemFromString(String StringName)
在 FreeTextBoxControls.ToolbarGenerator.ToolbarsFromString(String toolbarLayout)

刚开始以为加个
加个 <trust level= "Medium "/> 信任级别就能解决
<location allowOverride= "false ">
<system.web>
<!-- level= "[Full|High|Medium|Low|Minimal] " -->
<trust level= "Medium " originUrl= " "/>
</system.web>
</location>

后来出现

Server Error in '/ ' Application.
--------------------------------------------

Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: This configuration section cannot be used at this path. This happens when the site administrator has locked access to this section using <location allowOverride= "false "> from an inherited configuration file.

Source Error:


Line 10: <location allowOverride= "false ">
Line 11: <system.web>
Line 12: <securityPolicy>
Line 13: <trustLevel name= "Full " policyFile= "internal "/>
Line 14: <trustLevel name= "High " policyFile= "web_hightrust.config "/>

错误

<location allowOverride= "false ">
<system.web>
<securityPolicy>
<trustLevel name= "Full " policyFile= "internal "/>


<trustLevel name= "High " policyFile= "web_hightrust.config "/>
<trustLevel name= "Medium " policyFile= "web_mediumtrust.config "/>
<trustLevel name= "Low " policyFile= "web_lowtrust.config "/>
<trustLevel name= "Minimal " policyFile= "web_minimaltrust.config "/>
</securityPolicy>
<trust level= "full " originUrl= " " />

</system.web>
</location>

引用其它类似的方法,经过亲自测试的确是这个问题虚拟主机上asp.net运行权限不足问题


有些时候我们写的asp.net应用程序是运行在虚拟主机上。有一些虚拟主机可能是由于安全的考虑,对asp.net做了权限设置,会导致我们的应用程序无法正常运行。

问题现象:

由于某种原因,asp.net不能加载某些dll文件,出现如下错误提示: Server Error in '/ ' Application.
---------------------------------------------

Required permissions cannot be acquired.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Security.Policy.PolicyException: Required permissions cannot be acquired.

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:


[PolicyException: Required permissions cannot be acquired.]
System.Security.SecurityManager.ResolvePolicy(Evidence evidence, PermissionSet reqdPset, PermissionSet optPset, PermissionSet denyPset, PermissionSet& denied, Boolean checkExecutionPermission) +2738293
System.Security.SecurityManager.ResolvePolicy(Evidence evidence, PermissionSet reqdPset, PermissionSet optPset, PermissionSet denyPset, PermissionSet& denied, Int32& securitySpecialFlags, Boolean checkExecutionPermission) +57

[FileLoadException: Could not load file or assembly 'Microsoft.Practices.ObjectBuilder, Version=1.0.51205.0, Culture=neutral, PublicKeyToken=null ' or one of its dependencies. Failed to grant minimum permission requests. (Exception from HRESULT: 0x80131417)]
System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +0
System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +211
System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +141
System.Reflection.Assembly.Load(String assemblyString) +25
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +32




问题分析:
根据我的观察,asp.net应用程序直接生成的dll可以正常加载,由asp.net直接调用的外部dll也可以正常加载,但是仅被外部dll引用的其他外部dll不能加载。我的猜想是:由于权限是不完全的,asp.net应用本身生成的dll和直接引用的dll可以通过权限的继承获得权限,而仅被外部dll引用的其他外部dll因为权限的限制不能继承权限,因此出现了权限不足的问题。

问题解决:
通过在我电脑的试验,推测虚拟主机上修改了根web.config(在我电脑上其位置为C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG)的设置.
默认web.config的权限设置节如下:
<location allowOverride= "true ">
<system.web>
<securityPolicy>
<trustLevel name= "Full " policyFile= "internal " />
<trustLevel name= "High " policyFile= "web_hightrust.config " />
<trustLevel name= "Medium " policyFile= "web_mediumtrust.config " />


<trustLevel name= "Low " policyFile= "web_lowtrust.config " />
<trustLevel name= "Minimal " policyFile= "web_minimaltrust.config " />
</securityPolicy>
<trust level= "Full " originUrl= " " />
</system.web>
</location>
推测虚拟主机上修改之后的设置: <location allowOverride= "false ">
<system.web>
<securityPolicy>
<trustLevel name= "Full " policyFile= "internal " />
<trustLevel name= "High " policyFile= "web_hightrust.config " />
<trustLevel name= "Medium " policyFile= "web_mediumtrust.config " />
<trustLevel name= "Low " policyFile= "web_lowtrust.config " />
<trustLevel name= "Minimal " policyFile= "web_minimaltrust.config " />
</securityPolicy>
<trust level= "High " originUrl= " " />
</system.web>
</location> 他首先设置了allowOverride为false,这就阻止了在用户web.config中重新定义权限的能力。然后,他定义trust level为High,而不是默认的Full。经我测试,只要trust level不为Full,仅被外部dll引用的其他外部dll就不能被加载。 因此,我建议技术支持将allowOverride节设置为true。这样我就可以在web.config中重新指定权限了。
例: <trust level= "Full " originUrl= " " />



[解决办法]
我之前也碰到这个问题。弄了好久,好烦。。最后才搞定。lz 把邮箱给我。我发给实例给你看。你照着做就可以。

读书人网 >asp.net

热点推荐