在C#运行时加载Dll [英] Loading Dlls in C# runtime

查看:157
本文介绍了在C#运行时加载Dll的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友们,



我正在开发一个多语言Windows应用程序...

我为德语制作了两个类库和...并使用此脚本在运行时动态加载它..

Hi friends,

I am developing a Multi-Language windows application...
I have made two class libraries for German and English... and dynamically loading it in runtime using this script..

class Language
{
public static string title ;
public static LoadLanguage(string LangPath)
{
        Assembly LAsm = Assembly.LoadFrom(LangPath);
                    Type LType = LAsm.GetType("Lang.MyLang");
                    dynamic LangDllClass = Activator.CreateInstance(LType);
title = LangDllClass.title; 
}
}





脚本在主方法中被调用,并且每当用户更改语言时。 ..

它在第一次加载时效果很好,但是当我用不同的语言dll路径再次调用该函数时,它将不会加载新的dll,但只有旧的dll会在那里....



例如:如果我在主要方法中加载英语,即使我将Langauage更改为德语,也不会加载dll,大会将使用只有英文,,,



请帮助朋友,,,,我卡住了:(



The script is being called in main methode, and whenever a user changes the Language...
It works perfectly on first time load, but when I call the function again with different language dll path,,, it will not load the new dll, but The Only the Old dll will be there....

Eg: If I load English at the main methode, EVen if I change the Langauage to German, the dll wont be loaded, The Assembly will use the English only,,,

Please Help friends,,,, i am stuckk :(

推荐答案

参见...

使用反射来在运行时在C#中加载未引用的程序集 [ ^ ]

我可以在运行时加载.NET程序集并实例化一个类型只知道名字 [ ^ ]

在运行时动态加载DLL [ ^ ]
See...
Using Reflection to load unreferenced assemblies at runtime in C#[^]
Can I load a .NET assembly at runtime and instantiate a type knowing only the name[^]
dynamic loading of a DLL at run-time[^]


请参阅 Assembly.LoadFile与Assembly.LoadFrom - 最完整的.NET默认 [ ^ ]



干杯,

Edo
See Assembly.LoadFile versus Assembly.LoadFrom - .NET obscurity at its finest[^]

Cheers,
Edo


这篇关于在C#运行时加载Dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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