在新计算机上编译ASP.NET网站时无法生成代码错误 [英] Failed to generate code error when compiling a ASP.NET website on a new computer

查看:95
本文介绍了在新计算机上编译ASP.NET网站时无法生成代码错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过复制网站的整个文件夹将我的ASP.NET 4.5网站移到了新计算机上.当我尝试在Visual Studio 2012的新计算机上(与第一台计算机上的相同版本)构建网站时,会出现一些警告和错误.

I moved my ASP.NET 4.5 website to a new computer by copying the whole folder of the website. When I try to build the website on the new computer in Visual Studio 2012 (same version that I have on the first computer) I get a few warnning and Errors.

错误:

Failed to generate code. Exception of type 'System.Data.Design.InternalException' was thrown.   C:\Users\admin\Desktop\website_sample\App_Code\DataSet.xsd  

有21条警告,全部针对不同的dll文件说无法更新自动刷新引用" .

There are 21 warnnings, all saying "Unable to update auto-refresh reference" for different dll files.

当我尝试运行default.aspx页(在第一台计算机上运行良好)时,对于App_Code/DataSet.xsd文件,出现以下错误:

when I try to run my default.aspx page (worked great on the first computer), I get the following error for the App_Code/DataSet.xsd file:

Failed to generate code. Exception of type 'System.Data.Design.InternalException' was thrown.

还有源错误:

Line 1:  <?xml version="1.0" encoding="utf-8"?>
Line 2:  <xs:schema id="DataSet" targetNamespace="http://tempuri.org/DataSet.xsd" xmlns:mstns="http://tempuri.org/DataSet.xsd" xmlns="http://tempuri.org/DataSet.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:msprop="urn:schemas-microsoft-com:xml-msprop" attributeFormDefault="qualified" elementFormDefault="qualified">
Line 3:    <xs:annotation>

我正在使用MySQL .NET Connector,但是我已经在新计算机上安装了它,以确保这不会导致错误.

I am using MySQL .NET Connector, but I already intalled it on the new computer to make sure that this doesn't lead to the error.

我需要知道如何解决错误并发出警告.首先,我最担心该错误,因为它使我无法运行今天需要运行的一些任务.预先感谢.

I need to know how to solve the error and warnning. I am most concerned about the error first because it prevents me from running a few tasks that I need to run today. Thanks in advance.

我的假设是我使用了其他版本的.NET MySQL连接器,但我并不讨厌.

My assumption is that I used a different version of the .NET MySQL connector, but I'm not dure.

推荐答案

如果最初是通过从Visual Studio内部的数据库或服务器资源管理器中拖放来创建数据集的,则数据库引用在某些时候不再有效(移动/删除数据库),将导致此异常.

If you initially created the datasets by dragging and dropping from the Database or Server Explorer inside of Visual Studio, and the database reference at some point is no longer valid (moved/deleted the database), it will cause this exception.

这是由于Visual Studio在XSD内存储了连接字符串.如果该连接字符串不再有效,则无法动态生成所需的适配器.要解决此问题,请在XSD文件内部的Connection节点上更改ConnectionStringObject属性(不是在设计级别,而是在文本编辑器级别.)将其设置为指向数据集对应的数据库的有效连接字符串,您将很好.

It's due to the fact that Visual Studio stores the connection string within the XSD. If that connection string is no longer valid, it can't dynamically generate the needed adapters. To fix this, change the ConnectionStringObject attribute on the Connection node inside the XSD file (not at design level, but at the text editor level.) Set it to a valid connection string pointing to the database your dataset corresponds to, and you're good to go.

这篇关于在新计算机上编译ASP.NET网站时无法生成代码错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆