My resource files are in another project. In App.xaml.cs in MainwindowProject, I write code as below to load the resource file.
static ResourceBundle CreateResourceBundle()
{
string dllPath = System.IO.Directory.GetCurrentDirectory() + "\Trade.Resources.dll";
ResourceBundle resBundle = new ResourceBundle(Assembly.LoadFile(dllPath));
resBundle.LocaleRoot = "Trade.Resources.locale"; //where my locale files are
resBundle.AddResourceFile("Resources");
string culture = "en-US";
resBundle.Locale = culture;
System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo(culture);
return resBundle;
}
一些用户控制正在使用这一树脂。 该公司在经营时处以工作罚款。 但是, 如果我在设计时打开了母子午餐窗口,我就没有这个例外,不能装上用户控制。
The system cannot find the file specified. (Exception from HRESULT: 0x80070002)
at System.Reflection.RuntimeAssembly.nLoadFile(String path, Evidence evidence)
at System.Reflection.Assembly.LoadFile(String path)
如何解决这一问题? 感谢。
Edit: 临时工作
我刚刚增加了贸易的接口。 资源项目。 在App.xaml.cs中,情况如下。
Type iResType = Type.GetType("Trade.Resources.IRes,Trade.Resources", true);
ResourceBundle resBundle = new ResourceBundle(Assembly.GetAssembly(iResType));
至今,在设计时间和操作时间都处以工作罚款。