我最近将我的计算机升级到 XP 64 位,并对我们的软件进行了一些代码更改,当我执行 new XmlSerializer(valueType)
时,其中 valueType
是一种类型正在使用 DirectoryItem
,我收到以下错误:
无法生成临时类(结果=1)。
错误 CS0012:类型“XYZ.Blob.DirectoryItem”是在未引用的程序集中定义的。您必须添加对程序集“XYZ.Services.Blob,Version=1.0.0.0,Culture=neutral,PublicKeyToken=null”的引用。
我真的不明白为什么它显示这个错误。该 dll 位于 src 文件夹中,并且完全相同的应用程序在同一台计算机(以前的版本)上运行,没有任何问题。
如果您知道如何找到它给出的错误,那就太好了。
I recently upgrade my machine to XP 64 bit and also made some code changes to our software and when I'm doing new XmlSerializer(valueType)
, where valueType
is a type that is using DirectoryItem
, I'm getting the following error:
Unable to generate a temporary class (result=1).
error CS0012: The type 'XYZ.Blob.DirectoryItem' is defined in an assembly that is not referenced. You must add a reference to assembly 'XYZ.Services.Blob, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
I really can't see why it shows this error. The dll is in the src folder and the exact same application is running with no issue on the same machine (the previous version).
If you have any idea how can I find what it gives this error that would be great.
发布评论
评论(3)
您能否验证您不是 陷入这种不幸的情况?如果是这种情况,则这是 Microsoft 无法修复的错误:
您需要将某种类型放入程序集中 A:
并且需要在另一个程序集中序列化类型:
现在,尝试初始化 XmlSerializer
Can you verify that you are not falling in this unfortunate scenario? If this is the case that's a bug that won't be fixed by Microsoft:
You need some type into an assembly A:
And a type to be serialized in another assembly:
Now, try to initialize a XmlSerializer
您的程序集是为 x86 平台构建的。
查看您的项目的属性 ->构建->目标平台
默认是 x86。您需要重新编译 x64。
最好的选择是针对“任何”进行编译 - 根据您的情况。
Your assembly has been built for x86 platform.
Have a look at your project's properties -> build -> target platform
It is x86 by default. You need to recompile for x64.
Best option is compiling for "any" - in your case.
一旦我将所有隐式转换更改为显式转换,解决方案似乎就已修复。
感谢您的帮助。
it seems like that the solution was fixed once i changed all my implicit conversion to explicit ones.
thanks for the help.