错误实例通过传统的ASP .NET / COM互操作课的时候 [英] Error when instantiating .NET/COM interop class via classic ASP

查看:289
本文介绍了错误实例通过传统的ASP .NET / COM互操作课的时候的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图实例化一个已经暴露在COM在传统的ASP应用程序中的C#.NET类时,有一个问题。我用tlbexp生成类型库和组件服务注册它;现在尝试创建对象时,这样的:

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")

我收到错误:

I am getting the error:

服务器对象错误ASP 0177:80131534

Server.CreateObject失败

我四处寻找网上关于此错误的信息,并发现大量的讨论,但没有解决方案。错误code 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:

  • 在测试.NET项目中引用的DLL可以实例化类就好了;然而,测试VB6项目引用TLB吹了同样的错误。 DLL和TLB中都在相同的位置。
  • 在该应用程序是在本地运行,在Windows XP Professional SP3和IIS 5.1。
  • 在.NET程序集是建立与.NET框架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...

<一个href="http://social.msdn.microsoft.com/Forums/vstudio/en-US/4b021da2-3fc7-4f20-b3d0-0f90491a232e/regasm-not-registering-all-classes" rel="nofollow">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互操作课的时候的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆