获得班级的全限定名? [英] Get the fully qualified name of a class?

查看:48
本文介绍了获得班级的全限定名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所有,我有一个log4net实现,我正在尝试使用AdoNetAppender,但是appender配置的子元素之一是connectionType,它需要一个完全限定的类名,例如System.Data.SqlClient.SqlConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089(以文档为例).

All, I have a log4net implementation and I'm trying to use the AdoNetAppender, but one of the subelements for the appender configuration is connectionType and it requires a fully qualified class name like System.Data.SqlClient.SqlConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 (got that from the documentation as an example).

但是,由于这是一个.NET4 MVC应用程序,因此无法加载该文件.有人可以告诉我如何获取完全限定的名称,以便它可以加载类型并连接到数据库吗?我已经尝试了所有我能想到的一切.

However, it can't load that one because this is a .NET4 MVC application. Can somebody tell me how I can get that fully qualified name so it will load the type and connect to the database? I've tried everything that I can honestly think of.

推荐答案

我不确定您需要哪种类型,但是您可以在代码中使用此类型来获取类型的完全限定名称.

I'm not sure what type you need, but you can use this in code to get the fully qualified name of a type.

string fullyQualifiedName = typeof(MyType).AssemblyQualifiedName;

这篇关于获得班级的全限定名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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