本文介绍了通过程序集的字符串表示形式收集程序集类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的方法必须执行下一个操作:
我需要从Xml节点提供其他类型的模块,以便在Windows环境(Console,WPF)中的WCF中进一步托管.

Hi, my method must perform next action:
I need to provide additional module with types from Xml node for further hosting in WCF in windows enviroment(Console, WPF).

public Dictionary<Type, Type> GetServicesToBeHostedFromConfig(XElement configuration)
		{
			try
			{
				_Locker.EnterReadLock();
				Dictionary<Type, Type> returnTypes = new Dictionary<Type, Type>();

				foreach (var item in configuration.Descendants("Items"))
				{
		                  returnTypes[Type.GetType(item.Attribute("service").Value)] = Type.GetType(item.Attribute("contract").Value);
				}

				return returnTypes;
			}
			finally
			{
				_Locker.ExitReadLock();
			}
		}



一切正常,直到我尝试获取位于同一程序集中的类型,即我的方法所在的位置,
但是,当我尝试获取包含在另一个中的类型时,我会失败! (引用了我的主组件!)

我想我必须实现某种程序集解析机制,但是老实说,我不知道该怎么做...



everything work fine until i try to get types which located in the same assembly , where my method located ,
but when i try to get types which containt in another i get fail! (my main assembly referenced to it !)

I suppose i must to implement some assembly resolving mechanism , but if be honest, i dont know how to do it...

Maybe someone can help me with such issue?

推荐答案


这篇关于通过程序集的字符串表示形式收集程序集类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-21 09:36