情况:
RT.Servers包含一些资源(类型byte[],但我不认为这很重要)我收到MissingManifestResourceException以下消息:
找不到适合指定文化或中性文化的资源.确保"Servers.Resources.resources"在编译时正确嵌入或链接到程序集"RT.Servers",或者所有所需的附属程序集都是可加载和完全签名的.
我从来没有玩过文化,也没有集会签约,所以我不知道这里发生了什么.此外,这适用于使用相同库的另一个项目.有任何想法吗?
我已将所有应用程序的ResourceDictionaries放入一个单独的程序集中,并将它们合并到一个ResourceDictionary中,我希望将其作为资源包含在我的应用程序中:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="InputStyles.xaml"/>
<ResourceDictionary Source="DataGridStyles.xaml"/>
<ResourceDictionary Source="ComboboxStyles.xaml"/>
<ResourceDictionary Source="CheckboxStyles.xaml"/>
<ResourceDictionary Source="TabControlStyles.xaml"/>
<ResourceDictionary Source="ButtonStyles.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
Run Code Online (Sandbox Code Playgroud)
声明资源:
<Window.Resources>
<ResourceDictionary Source="pack://application:,,,/StyleAssembly;component/Styles.xaml"/>
</Window.Resources>
Run Code Online (Sandbox Code Playgroud)
在VS中查看设计器所有控件都显示文件中的样式,但是当我尝试启动应用程序时,我收到以下错误:
"找不到资源'inputstyles.xaml'."
所有文件的构建操作都设置为"页面",两个项目的构建都成功.我究竟做错了什么?
我正在开发一个用户控件并在ElementHost中使用它.我定义资源字典如下:
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Themes/Classic.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
Run Code Online (Sandbox Code Playgroud)
在我的VS资源管理器中,我有这个
Project (the user control library)
|_ Themes
|__ Generic.xaml (Build Action = Page)
|__ Classic.xaml (Build Action = Page)
Run Code Online (Sandbox Code Playgroud)
没有编译错误,VS设计师似乎拿起了Classic.xaml中定义的资源
但是,它在运行时崩溃,但有以下异常:
System.Reflection.TargetInvocationException:调用目标抛出了异常.---> System.Reflection.TargetInvocationException:调用目标抛出了异常.---> System.Reflection.TargetInvocationException:调用目标抛出了异常.---> System.Windows.Markup.XamlParseException:'Set property'System.Windows.ResourceDictionary.Source'抛出异常.' 行号"16"和行位置"18".---> System.IO.IOException:找不到资源'themes/classic.xaml'.
这是怎么回事?
我在命令行上使用MSBuild在构建服务器上的C#项目的嵌入资源有问题.在Visual Studio中构建和运行测试时,该项目工作得很好,但是当从命令行运行MSBuild时,运行测试时会出现以下问题:
System.Resources.MissingManifestResourceException:找不到适合指定文化或中性文化的任何资源.确保".Properties.Resources.resources"在编译时正确嵌入或链接到程序集"",或者所有所需的附属程序集都是可加载和完全签名的.
System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo requestedCulture,Boolean)中的System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet(CultureInfo文化,Dictionary`2 localResourceSets,Boolean tryParents,Boolean createIfNotExists,StackCrawlMark和stackMark)中的System.Resources.ManifestBasedResourceGroveler.HandleResourceStreamMissing(String fileName)位于System.Resources.get_SomeResource()的System.Resources.ResourceManager.GetString(String name,CultureInfo culture)的System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture,Boolean createIfNotExists,Boolean tryParents)中的createIfNotExists,Boolean tryParents,StackCrawlMark和stackMark\Properties\Resources.Designer.cs:第87行
我已将问题跟踪到生成的IL(我使用ildasm).在Visual Studio中进行扩展时,在程序集的清单中设置以下内容:
.mresource public <PROJECTNAME>.Properties.Resources.resources
{
// Offset: 0x00000000 Length: 0x00000236
}
Run Code Online (Sandbox Code Playgroud)
但是在使用MSBuild构建时会生成以下输出:
.mresource public '../..//Build/<PROJECTNAME>_AnyCPU_Debug_Obj/<PROJECTNAME>.Properties.Resources.resources'
{
// Offset: 0x00000000 Length: 0x00000236
}
Run Code Online (Sandbox Code Playgroud)
因为可以看到资源的路径突然成为资源名称的一部分.
有没有人有任何想法如何解决这个问题?