相关疑难解决方法(0)

生成Xml序列化程序集作为构建的一部分

此代码生成FileNotFoundException,但最终运行没有问题:

void ReadXml()
{
    XmlSerializer serializer = new XmlSerializer(typeof(MyClass));
    //...
}
Run Code Online (Sandbox Code Playgroud)

这是一个例外:


mscorlib.dll中出现"System.IO.FileNotFoundException"类型的第一次机会异常

附加信息:无法加载文件或程序集"MyAssembly.XmlSerializers,Version = 1.4.3190.15950,Culture = neutral,PublicKeyToken = null"或其依赖项之一.该系统找不到指定的文件.


如果找不到,框架似乎会自动生成序列化程序集. 我可以使用sgen.exe手动生成它,这可以缓解异常.

如何让visual studio自动生成XML序列化程序集?


更新:生成序列化程序集:打开设置似乎没有做任何事情.

c# xml xml-serialization

64
推荐指数
4
解决办法
6万
查看次数

无法生成临时类(result = 1).错误CS0030:无法将类型'Type []'转换为'Type'?

我使用xsd.exe工具从我的xsd文件创建一个类后出现此错误.所以我在网上搜索并找到了解决方案.这是链接:http://satov.blogspot.com/2006/12/xsdexe-generated-classes-causing.html

问题是这会使代码运行,但不知何故反序列化数据似乎已损坏.我做了网站建议的内容,最后第二个数组维度总是空的(参见网站的评论,有人也有这个问题).问题是,我现在该如何解决这个问题?是否有另一种工具来创建xsd文件?我尝试过Xsd2Code,没有成功.

谢谢 :-)

c# xsd xml-deserialization

48
推荐指数
4
解决办法
4万
查看次数

错误:无法生成临时类(result = 1)...在Web服务上调用方法时

错误:无法生成临时类(result = 1)...在Web服务上调用方法时.我正在使用VS 2008 C#ASP.NET 3.5.我正在为我的应用程序调用远程Web服务.

Server Error in '/' Application.
Server was unable to process request. ---> Unable to generate a temporary class (result=1).
error CS2001: Source file 'C:\WINDOWS\TEMP\6sbkwt2d.0.cs' could not be found
error CS2008: No inputs specified
 Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

 Exception Details: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> …
Run Code Online (Sandbox Code Playgroud)

c# asp.net web-services .net-framework-version

19
推荐指数
1
解决办法
2万
查看次数