开发者

WPF error CS0433

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'


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


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.


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.


I tried to figure out why I've got this generated class XamlGeneratedNamespace.GeneratedInternalTypeHelper in my library. MSDN says nothing helpful:

A class generated by the workflow designer used to generate CLR types for XAML documents.

But I found the line of code which causes generation of this class:

<Grid DataContext="{TemplateBinding InternalDataContext}">

I replaced it with "runtime equivalent":

<Grid DataContext="{Binding InternalDataContext, RelativeSource={RelativeSource TemplatedParent}}">

Maybe it may help somebody.


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:

<system.xml.serialization> 
  <xmlSerializer tempFilesLocation="c:\\foo"/> 
</system.xml.serialization> 

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜