在远程托管服务器上运行的 ASP.NET 应用程序中,我收到此错误:
无法从程序集“my assembly,Version=1.0.0.0,Culture=neutral,PublicKeyToken=null”加载类型“mshtml.IHTMLDocument”。该类型被标记为符合类型等效条件,但包含的程序集未加载为完全受信任。
当调用我的函数但在函数体中执行任何内容之前,会触发此异常。 (正文包含对 IHTMLDocument2 doc = (IHTMLDocument2)new HTMLDocument();
的调用等)所以我猜这是函数序言中的错误? 正如我正确理解的那样,
这个程序集 mshtml 将嵌入到我的程序集中(因为“嵌入互操作 Tyoes”设置为 true)。我想保持这种状态。同时给予它充分的信任。 (从异常消息中也不清楚谁应该获得完全信任,从谁那里得到完全信任?我的程序集来自托管管理员还是来自我的 mshtml?)
我实际上尝试给予它完全信任,就像这样 无法加载类型 Microsoft.Office.Interop.Excel._Application 主题,我将其设置在 Web 中。 config 在服务器上的根目录中,但管理员似乎设置了
并禁用了它。 ,不知道这是否与我想要完成的事情有关。这是从我信任的 mshtml 程序集中调用一些函数,因为它(部分?)嵌入在我创建的程序集中,并且它不应该需要更高的权限(它只是从给定的字符串解析 HTML)
In ASP.NET application run on remote hosting server i get this error:
Could not load type 'mshtml.IHTMLDocument' from assembly 'myassembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. The type is marked as eligible for type equivalence, but the containing assembly is not loaded as fully trusted.
this Exeption triggers when my function is called but before it gets to execute anything in function body. (body contains call to IHTMLDocument2 doc = (IHTMLDocument2)new HTMLDocument();
among other things) So i guess it is error in function prolog then? wierd
this assembly mshtml will be embedded into my assembly as i understand correctly (Because "Embed interop Tyoes" is set to true). And i want to keep it that way. And at the same time grant it full trust. (It is also not clear from exception message who should get full trust and from whom? my assembly from hosting admin or mshtml from me? )
I actually tried give it full trust like in this Could not load type Microsoft.Office.Interop.Excel._Application topic, i set it inside Web.config in my root directory on server, but it seems that admin set <location allowOverride="false">
and disabled that. , dont' know if that has to do anything with what i want to acomplish. and that is call some function from mshtml assembly wich i trust because it is (partially?) embedded in assembly that i created, and it should not require higher priviledges (it just parses HTML from given string)
发布评论