在 Unity 配置文件中使用 Microsoft.NET 标准库类型

发布于 2024-09-07 01:39:57 字数 630 浏览 1 评论 0原文

我正在尝试在我的配置文件中注册类型转换,如下所示:

<param name="connectionString" parameterType="System.String">
    <value value="MyDbConnection" 
        type="System.Configuration.ConnectionStringSettings" 
        typeConverter="ConnectionStringSettingsTypeConverter" />
</param>

我收到标准无法加载类型错误

无法从程序集“Microsoft.Practices.Unity.Configuration”加载类型“System.Configuration.ConnectionStringSettings” , ...etc

为什么它尝试从 Unity 程序集中加载类型?我需要添加什么才能让 Unity 找到正确的程序集?

我想因为我使用的是完全限定名称,所以它应该可以工作。

编辑:注意我使用的是 1.2 版本。 2.0版本的schema中有一个标签,但是1.2版本好像没有这个标签。

I am trying to register a type conversion in my config file as follows:

<param name="connectionString" parameterType="System.String">
    <value value="MyDbConnection" 
        type="System.Configuration.ConnectionStringSettings" 
        typeConverter="ConnectionStringSettingsTypeConverter" />
</param>

I am getting the standard can't load type error

Could not load type 'System.Configuration.ConnectionStringSettings' from assembly 'Microsoft.Practices.Unity.Configuration, ...etc

Why is it trying to load the type from the Unity assembly? What do I need to add for Unity to locate the correct assembly?

I thought because I was using the fully qualified name, it should just work.

Edit: note I am using version 1.2. The 2.0 version has an tag in the schema, but 1.2 doesn't seem to have this tag.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我早已燃尽 2024-09-14 01:39:58

您没有使用真正完全限定的类型名称 - 您还需要提供程序集名称。试试这个:

type="System.Configuration.ConnectionStringSettings,System.Configuration"

You're not using the really fully qualified type name - you need to provide the assembly name as well. Try this:

type="System.Configuration.ConnectionStringSettings,System.Configuration"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文