WPF 错误 CS0433
我在 WPF 应用程序中收到此错误。我并不总是收到此错误。如果我清理然后重建一切都可以。
SGEN (0,0):
error: Unable to generate a temporary class (result=1).
SGEN (0,0):
errorCS0433: The type 'XamlGeneratedNamespace.GeneratedInternalTypeHelper' exists in both 'library1.dll' and 'library2.dll'
I'm getting this error in my WPF application. I get this error not always. If I make Clean and then Rebuild everything is ok.
SGEN (0,0):
error: Unable to generate a temporary class (result=1).
SGEN (0,0):
errorCS0433: The type 'XamlGeneratedNamespace.GeneratedInternalTypeHelper' exists in both 'library1.dll' and 'library2.dll'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您可以使用 RummageTypeRenamer,这是一个与我们的混淆器 Rummage 捆绑在一起的免费工具(我在 Aldaray 工作) ,将
GeneratedInternalTypeHelper
类型重命名为其他类型。我们将其重命名为
GeneeratedInternalTypeHelper$(ProjectName)
之类的名称,以便它在项目中是唯一的并且不会发生冲突。我们在所有构建脚本中都这样做以使 ILMerge 正常工作(我同事的博客条目私人博客)。You could use RummageTypeRenamer, a free tool bundled with our obfuscator Rummage (I work for Aldaray), to rename the
GeneratedInternalTypeHelper
type to something else.We rename it to something like
GeneratedInternalTypeHelper$(ProjectName)
so that it is unique across projects and never clashes. We do that in all our build scripts to get ILMerge to work (blog entry in my colleague’s private blog).这是 Scott Hanselman 的一篇文章,讨论了 WPF 的这个问题。
其他遇到此问题的人已通过安装一些修补程序修复了该问题。请查看本文了解更多信息。
如果您使用的是 Citrix,您可能需要查看一下。您可能遇到权限问题。本文讨论的是 ASP .NET 应用程序,但您的 WPF 应用程序中可能会遇到类似的问题。这是一个很好的起点。
Here's an article by Scott Hanselman discussing this issue for WPF.
Other people that have had this problem have fixed it by installing some hotfixes. Check out this article for more information.
If you're using Citrix, you might want to check this out. You could have a permissions issue. This particular article deals with an ASP .NET application, but you might have a similar issue in your WPF application. It's a good place to start.
此错误来自持久编译的 XML 序列化程序集生成器。它从 XML 可序列化类型生成类。如果您不使用此选项,则可以在项目属性中取消选中此选项。
This error comes from the persistent compiled XML serialization assembly generator. It generates classes from XML serializable types. If you don't use this, you can uncheck this in project properties.
我试图弄清楚为什么我的库中有这个生成的类 XamlGenerateNamespace.GenerateInternalTypeHelper 。 MSDN 说没有任何帮助:
但我找到了导致生成此类的代码行:
我将其替换为“运行时等效项”:
也许它可能会对某人有所帮助。
I tried to figure out why I've got this generated class XamlGeneratedNamespace.GeneratedInternalTypeHelper in my library. MSDN says nothing helpful:
But I found the line of code which causes generation of this class:
I replaced it with "runtime equivalent":
Maybe it may help somebody.
您可以在 c:\Users\\AppData\Local\Temp\ 中找到 XmlSerializer 生成的代码
运行你的应用程序后,它将是something.cs。
我的是:“me2ywucq.0.cs”,只需在代码中文本搜索您的类型名称。
您还可以更改在运行时创建程序集时写入代码的路径
请参阅 更改 XmlSerializer 输出临时程序集的位置(作者:scott)
将以下内容添加到您的 app.config 或 web.config 中:
找到代码后,您可以自行将其编译到 myAssembly.XmlSerializers.dll 中或在代码中实现 IXmlSerializer,而不会破坏与先前序列化的兼容性。
you can find the XmlSerializer's generated code in c:\Users\\AppData\Local\Temp\
after running your application, it'll be something.cs.
Mine was: "me2ywucq.0.cs", just text search for your Type name inside it's code.
You can also change the path it writes the code to when it creates assemblies at runtime
see Changing where XmlSerializer Outputs Temporary Assemblies by scott
Add the following to your app.config or web.config:
After finding the code you can compile it yourself into an myAssembly.XmlSerializers.dll or implement IXmlSerializer in your code, without breaking compatibility with prev serializations.