我在Visual Studio 2015中创建了一个MVC网站,它可以在我的localhost中运行.但是当我发布我的网站并放入我的主机时,它不起作用.它给了我这个错误通知:
'/'应用程序中的服务器错误.
配置错误
分析器错误消息:Web.config文件元素中的"targetFramework"属性仅用于目标4.0版及更高版本的.NET Framework(例如,'')."targetFramework"属性当前引用的版本晚于安装的.NET Framework版本.指定.NET Framework的有效目标版本,或安装所需的.NET Framework版本.
来源错误:
服务器上发生应用程序错误.此应用程序的当前自定义错误设置可防止远程查看应用程序错误的详细信息(出于安全原因).但是,它可以由运行在本地服务器计算机上的浏览器查看.
源文件:G:\ xxx\xxx.com\httpdocs\web.config行:24
版本信息:Microsoft .NET Framework版本:4.0.30319; ASP.NET版本:4.0.30319.34248
我的web.config中的相关部分:
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections>
Run Code Online (Sandbox Code Playgroud)
这部分有错误:
<system.web>
<authentication mode="None" />
<customErrors mode="Off" />
<compilation debug="true" targetFramework="4.6" />
<httpRuntime targetFramework="4.6" />
</system.web>
Run Code Online (Sandbox Code Playgroud)
我的网站的属性:
和NuGet包管理器:
EntityFramework参考属性:
默认网站基本设置:(说实话,我不确定是否应该在这里添加一个新网站(我的网站).)
我安装的.net框架:
我的发布方法:
我在互联网上调查了这个问题,我发现了几个与我的问题相关的链接:Asp.net MCV4框架问题.在此链接中,有两个主要优惠:
更改此编译标记
在IIS中更新应用程序池
实际上,我试图改变这个标签,但它没有改变.然后我控制了我的应用程序池,但它似乎是最新的.
我打电话给我的主机提供商,我已经解释了我的问题.他们说这个错误与他们的服务器无关.
我该怎么办?这是什么解决方案?
我想填写一个excel文件,所以我使用ExcelPackage:Office Open XML格式.但我有一个错误.我的代码:
string fileName = "DBE_BAKIM_FORMU" + ".xlsx";
FileInfo fi = new FileInfo(HttpContext.Current.Server.MapPath("~/") + fileName);
using (ExcelPackage xlPackage = new ExcelPackage(fi))
{
ExcelWorksheet worksheet = xlPackage.Workbook.Worksheets[1];
dbeDataContext db = new dbeDataContext();
CAGRI c = (from x in db.CAGRIs where x.CagriID == ID select x).SingleOrDefault();
USER u = (from x in db.USERs where x.UserID == Convert.ToInt32(Session["user"]) select x).SingleOrDefault();
worksheet.Cell(6, 3).Value = c.TalepTarihi.ToShortDateString();
worksheet.Cell(7, 3).Value = c.TalepTuru;
worksheet.Cell(8, 3).Value = c.ModulAdi;
worksheet.Cell(9, 3).Value = c.EkranRaporAdi;
worksheet.Cell(10, 3).Value = c.VerilenSure;
worksheet.Cell(11, 4).Value …Run Code Online (Sandbox Code Playgroud) c# asp.net visual-studio-2010 nullreferenceexception excelpackage
我有一个列表框,当我从这个列表框中选择一个名为ListofKBrands1的项目时,我会收到以下错误消息:
ObjectContext实例已被释放,不能再用于需要连接的操作.
在代码隐藏中,出现此错误:
if (co.Company != null)
Run Code Online (Sandbox Code Playgroud)
我的代码:
private void ListofKBrands1_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
RSPDbContext c = new RSPDbContext();
if (ListofKBrands1.SelectedItem != null)
{
ListBoxItem item = ListofKBrands1.SelectedItem as ListBoxItem;
KBrand co = item.Tag as KBrand;
if (ListofKBrands1.SelectedItem != null)
txtNewKBrand.Text = co.Name;
else
txtNewKBrand.Text = "";
int count = 0;
if (co.Company != null)
{
foreach (string a in cbCompany.Items)
{
if (a == co.Company.Name)
cbCompany.SelectedIndex = count;
count++;
}
}
else
cbCompany.SelectedIndex = 0;
}
}
Run Code Online (Sandbox Code Playgroud)
错误之前: …
我想根据登录的相关用户启用或禁用特定行.所以我使用rowdatabound事件,但我在这一行有一个错误:
DataRow drv = ((DataRowView)e.Row.DataItem).Row;
Run Code Online (Sandbox Code Playgroud)
在这里,e.Row.DataItem具有相关的行信息.我控制了它,它有行的值.但是当我想继续时,我会接受这个错误:
无法将类型为"<> f__AnonymousType0
14[System.Int32,System.Int32,System.String,System.String,System.DateTime,System.String,System.String,System.String,System.String,System.String,System.String,System.Nullable1 [System.DateTime],System.String,System.Nullable .1 [System.Boolean]]'的对象转换为"System.Data.DataRowView".
然后我改变了这一行:
DataRowView drv = e.Row.DataItem as DataRowView;
Run Code Online (Sandbox Code Playgroud)
对于这种情况,它没有给出错误,但是drv仍然是空值.Dataitem不会分配其值.
在这里,相关的完整代码:
protected void gvListele_RowDataBound(object sender, GridViewRowEventArgs e)
{
dbeDataContext db = new dbeDataContext();
var c = (from v in db.CAGRIs where v.UserID != Convert.ToInt32(Session["user"]) select v).ToArray();
if (c != null)
{
foreach (var item in c)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DataRow drv = ((DataRowView)e.Row.DataItem).Row;
int tempID = Convert.ToInt32(drv["CagriID"].ToString());
if (item.CagriID == tempID)
{
e.Row.Enabled = false;
} …Run Code Online (Sandbox Code Playgroud) 当我更改行中任何单元格的值时,我想动态更改同一行中的其他单元格.例如,在以下网格中,当我在第二行中将1更改为3时,值5必须更改为3. (编辑按钮仅将更改保存到数据库中.)

这是我的xaml代码DataGrid.我尝试过使用SelectedCellsChanged和SelectionChanged事件,但我没有成功.
<DataGrid x:Name="MyDataGrid" x:Uid="MyDataGrid" AutoGenerateColumns="False"
Height="226" HorizontalAlignment="Left" Margin="106,111,0,0"
VerticalAlignment="Top" Width="684" ColumnWidth="*"
AlternationCount="2" SelectionMode="Single"
SelectedCellsChanged="MyDataGrid_SelectedCellsChanged"
SelectionChanged="MyDataGrid_SelectionChanged" >
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Path=ProductName}" Header="Ürün Ad?" />
<DataGridTextColumn Binding="{Binding Path=StoreName}" Header="?ube Ad?" />
<DataGridTextColumn Binding="{Binding Path=Day1}" Header="Pazartesi" />
<DataGridTextColumn Binding="{Binding Path=Day2}" Header="Sal?" />
<DataGridTextColumn Binding="{Binding Path=Day3}" Header="Çar?amba" />
<DataGridTextColumn Binding="{Binding Path=Day4}" Header="Per?embe" />
<DataGridTextColumn Binding="{Binding Path=Day5}" Header="Cuma" />
<DataGridTextColumn Binding="{Binding Path=Day6}" Header="Cumartesi" />
<DataGridTextColumn Binding="{Binding Path=Day7}" Header="Pazar" />
<DataGridTemplateColumn Header="Edit Row">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Content="Edit" Click="EditButton_Click" …Run Code Online (Sandbox Code Playgroud) c# ×4
asp.net ×3
.net ×2
wpf ×2
asp.net-mvc ×1
excelpackage ×1
gridview ×1
rowdatabound ×1
wpfdatagrid ×1