1. <small id='jTZdw'></small><noframes id='jTZdw'>

  2. <legend id='jTZdw'><style id='jTZdw'><dir id='jTZdw'><q id='jTZdw'></q></dir></style></legend>

    1. <tfoot id='jTZdw'></tfoot>

      <i id='jTZdw'><tr id='jTZdw'><dt id='jTZdw'><q id='jTZdw'><span id='jTZdw'><b id='jTZdw'><form id='jTZdw'><ins id='jTZdw'></ins><ul id='jTZdw'></ul><sub id='jTZdw'></sub></form><legend id='jTZdw'></legend><bdo id='jTZdw'><pre id='jTZdw'><center id='jTZdw'></center></pre></bdo></b><th id='jTZdw'></th></span></q></dt></tr></i><div id='jTZdw'><tfoot id='jTZdw'></tfoot><dl id='jTZdw'><fieldset id='jTZdw'></fieldset></dl></div>
        <bdo id='jTZdw'></bdo><ul id='jTZdw'></ul>

      通过经典 ASP 实例化 .NET/COM 互操作类时出错

      时间:2023-07-26

      <small id='6Q9Wv'></small><noframes id='6Q9Wv'>

        <bdo id='6Q9Wv'></bdo><ul id='6Q9Wv'></ul>
          • <i id='6Q9Wv'><tr id='6Q9Wv'><dt id='6Q9Wv'><q id='6Q9Wv'><span id='6Q9Wv'><b id='6Q9Wv'><form id='6Q9Wv'><ins id='6Q9Wv'></ins><ul id='6Q9Wv'></ul><sub id='6Q9Wv'></sub></form><legend id='6Q9Wv'></legend><bdo id='6Q9Wv'><pre id='6Q9Wv'><center id='6Q9Wv'></center></pre></bdo></b><th id='6Q9Wv'></th></span></q></dt></tr></i><div id='6Q9Wv'><tfoot id='6Q9Wv'></tfoot><dl id='6Q9Wv'><fieldset id='6Q9Wv'></fieldset></dl></div>

            <legend id='6Q9Wv'><style id='6Q9Wv'><dir id='6Q9Wv'><q id='6Q9Wv'></q></dir></style></legend>
            <tfoot id='6Q9Wv'></tfoot>

                  <tbody id='6Q9Wv'></tbody>
              1. 本文介绍了通过经典 ASP 实例化 .NET/COM 互操作类时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我在尝试实例化在经典 ASP 应用程序中暴露给 COM 的 C# .NET 类时遇到问题.我已经使用 tlbexp 生成了一个 typelib 并在 Component Services 中注册了它;现在尝试这样创建对象时:

                I am having a problem when trying to instantiate a C# .NET class that's been exposed to COM in a classic ASP application. I've used tlbexp to generate a typelib and registered it in Component Services; now when trying to create the object as such:

                Server.CreateObject("The.Class.Name")
                

                我收到错误:

                服务器对象错误 'ASP 0177 : 80131534'

                Server.CreateObject 失败

                我在网上搜索了有关此错误的信息,发现了很多讨论但没有解决方案.错误代码 0x80131534 显然意味着COR_E_TYPEINITIALIZATION,类型无法初始化",这表明问题出在构造函数中.相关类的构造函数将私有字段设置为来自同一程序集的另一个类的实例,然后从 XML 文件中读取一些配置设置.此行为经过单元测试,我已检查该文件是否存在;我看不到任何其他可能闯入其中的东西.

                I've searched around online for information on this error, and found numerous discussions but no solution. The error code 0x80131534 apparently means "COR_E_TYPEINITIALIZATION, a type failed to initialize", which would suggest the problem would be in the constructor. The constructor of the class in question sets a private field to an instance of another class from the same assembly, and then reads some configuration settings from an XML file. This behaviour is unit tested and I've checked that the file exists; I can't see anything else that could be breaking in there.

                其他几点可能有用也可能没用:

                A few other points which may or may not be of use:

                • 引用 DLL 的测试 .NET 项目可以很好地实例化该类;然而,一个引用 TLB 的测试 VB6 项目因同样的错误而崩溃.DLL 和 TLB 都在同一个位置.
                • 此应用程序在 Windows XP Professional SP3 和 IIS 5.1 上本地运行.
                • .NET 程序集是使用 .NET Framework 2.0 构建的,尽管机器上安装了 3.5.

                我知道其他人在他们的构建中没有遇到这个错误,所以我相信这可能是环境问题.欢迎任何建议,因为我一直在努力解决这个问题.

                I know other people who don't get this error on their builds, so I believe it may be something environmental. Any suggestions are welcome as I've been struggling to fix this for some time.

                提前致谢.

                推荐答案

                我们遇到了与具有构造函数的类完全相同的问题.有趣的是,只有在较旧的服务器上,较新的服务器才能正常工作.

                We had exactly the same problem with a class that had a constructor. Funnily enough only on older servers, newer ones would work fine.

                我们通过添加一个空白的公共默认构造函数来修复它...

                We fixed it by adding in a blank public default constructor...

                public class MyClass
                {
                    public string MyGString
                    {
                        get; set;
                    }
                
                    //Com Fix
                    public MyClass(){}
                
                    //Normal Class
                    public MyClass(string myString)
                    {
                        HashAlgorithm = hashType;
                    }
                

                有人跟我有同样的问题...

                Someone with the same problem to me...

                http://social.msdn.microsoft.com/Forums/vstudio/en-US/4b021da2-3fc7-4f20-b3d0-0f90491a232e/regasm-not-registering-all-classes

                较新的服务器具有此版本的 RegAsm 2.0.50727.5420 旧的服务器具有此版本 2.0.50727.3053 这可能与它在没有空白公共默认构造函数的情况下工作的原因有关.

                Newer servers had this version of RegAsm 2.0.50727.5420 old ones had this version 2.0.50727.3053 This could be something to do with why it worked without a blank public default constructor.

                这篇关于通过经典 ASP 实例化 .NET/COM 互操作类时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:通过 COM 互操作公开 C# 类 下一篇:无需注册即可使用 OCX

                相关文章

                <legend id='svxBp'><style id='svxBp'><dir id='svxBp'><q id='svxBp'></q></dir></style></legend>

              2. <tfoot id='svxBp'></tfoot>
                  <bdo id='svxBp'></bdo><ul id='svxBp'></ul>
              3. <i id='svxBp'><tr id='svxBp'><dt id='svxBp'><q id='svxBp'><span id='svxBp'><b id='svxBp'><form id='svxBp'><ins id='svxBp'></ins><ul id='svxBp'></ul><sub id='svxBp'></sub></form><legend id='svxBp'></legend><bdo id='svxBp'><pre id='svxBp'><center id='svxBp'></center></pre></bdo></b><th id='svxBp'></th></span></q></dt></tr></i><div id='svxBp'><tfoot id='svxBp'></tfoot><dl id='svxBp'><fieldset id='svxBp'></fieldset></dl></div>

                1. <small id='svxBp'></small><noframes id='svxBp'>