English 中文(简体)
大会。 LoadFile无法在设计时间找到档案
原标题:Assembly.LoadFile cannot find the file at the design time

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));

至今,在设计时间和操作时间都处以工作罚款。

问题回答

制作“输出目录”资源档案财产供浏览。 通过这样做,你的资源档案将抄送执行大会的本名录。 即便如此工作,也使你的资源成为一种内在的资源,并试图从表面上看。

我不敢肯定,一旦你将资源档案的制片制成版,然后仅仅装上文件,那么你就应当工作。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签