我有一个基于ASP.NET Web表单的应用程序,它也支持MVC 5.我在我的项目中包含了MVC 5 API控制器,我必须将Json从4.5版升级到7.0版.在我启动应用程序后进行这些更改后,出现以下错误:
无法加载文件或程序集"System.Web.Mvc"或其依赖项之一.定位的程序集的清单定义与程序集引用不匹配.(HRESULT异常:0x80131040)
我检查了参考文献System.Web.Mvc.在属性对话框中,运行时版本v4.0.30319和版本是5.0.0.0.在web.config中,程序集设置如下:
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="NLog" publicKeyToken="5120e14c03d0593c" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.1.0" newVersion="2.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="AntiXssLibrary" publicKeyToken="d127efab8a9c114f" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.3.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
<!--<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" />
</dependentAssembly>-->
<dependentAssembly>
<assemblyIdentity …Run Code Online (Sandbox Code Playgroud) 我有一个在 Visual Studio 2013 环境中构建的项目,其中 Db 首先使用 EF 5 代码构建。我的 API 已经运行良好很长时间了,但突然间我开始收到以下错误消息:
无法更新数据库以匹配当前模型,因为存在未决更改且自动迁移已禁用。将挂起的模型更改写入基于代码的迁移或启用自动迁移。将 DbMigrationsConfiguration.AutomaticMigrationsEnabled 设置为 true 以启用自动迁移。
当我尝试到达 API 的终点时。我尝试添加一个新的迁移,然后更新数据库,但仍然出现错误。然后我删除整个数据库并使用 EF 重新创建。我的 API 的端点开始正常工作,但随后我又开始在网页上收到此错误。我在配置文件中将自动迁移设置为 true。我真的不知道为什么这一次又一次地发生。这让我真的很沮丧。这是错误的完整堆栈跟踪:
[AutomaticMigrationsDisabledException:无法更新数据库以匹配当前模型,因为存在挂起的更改并且自动迁移被禁用。将挂起的模型更改写入基于代码的迁移或启用自动迁移。将 DbMigrationsConfiguration.AutomaticMigrationsEnabled 设置为 true 以启用自动迁移。]
System.Data.Entity.Migrations.DbMigrator.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId) +579 System.Data.Entity.Migrations.DbMigrator.UpdateInternal(String targetMigration) +445
System.Data.Entity.Migrations.<>c__DisplayClassc.b__b() +13
System.Data.Entity.Migrations.DbMigrator.EnsureDatabaseExists(Action mustSucceedToKeepDatabase) +422
System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration) +78
System.Data.Entity.Migrations.Infrastructure.MigratorBase.Update() +12 YourTimeSite.Global.ApplyDatabaseMigrations() in c:\Users\Ahmed\Desktop \YourTimeSite\YourTimeSite\Global.asax.cs:55
YourTimeSite.Global.Application_Start(Object sender, EventArgs e) in c:\Users\Ahmed\Desktop\YourTimeSite\YourTimeSite\Global.asax.cs:32[HttpException (0x80004005): 无法更新数据库以匹配当前模型,因为存在挂起的更改并且禁用了自动迁移。将挂起的模型更改写入基于代码的迁移或启用自动迁移。将 DbMigrationsConfiguration.AutomaticMigrationsEnabled 设置为 true 以启用自动迁移。]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +9966013
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[]
系统处理程序) +1 .Web.HttpApplication.InitSpecial(HttpApplicationState …
我正在尝试使用 EF 核心 2 代码优先方法添加迁移。问题是,具有外键关系的实体是使用末尾带有“1”后缀的外键 id 和具有相同名称但末尾没有 1 的冗余列创建的,这不是外键。
示例是我的 2 个类,Store 和 StoreVisit,如下所示:
店铺
[Table("Store")]
public class Store
{
public Store()
{
StoreVisits = new HashSet<StoreVisit>();
}
[Key]
public int StoreId { get; set; }
[StringLength(30)]
public string ShopName { get; set; }
[StringLength(50)]
public string ShopKeeper { get; set; }
public string ContactNo { get; set; }
[StringLength(70)]
public string Address { get; set; }
[StringLength(20)]
public string Street { get; set; }
[StringLength(50)]
public string City { …Run Code Online (Sandbox Code Playgroud) entity-framework-core asp.net-core-2.0 entity-framework-core-migrations
我正在使用Xamarin构建一个Android应用程序.该应用程序的要求是从摄像头捕获视频并对视频进行编码以将其发送到服务器.最初我在服务器端使用编码器库对录制的视频进行编码,但事实证明,这对于大型视频文件来说非常不可靠和低效.我已将问题发布在另一个线程上,然后我决定在客户端对视频进行编码,然后将其发送到服务器.我发现编码有点复杂,关于如何做到这一点的信息不多,所以我搜索了解如何使用ffmpeg编解码器对视频进行编码的唯一方法.我找到了一些解决方案.github上有一个项目,演示了如何在Xamarin android项目中使用ffmpeg.但是,运行解决方案不会产生任何输出.该项目有一个二进制ffmpeg文件,使用以下代码安装到手机目录:
_ffmpegBin = InstallBinary(XamarinAndroidFFmpeg.Resource.Raw.ffmpeg, "ffmpeg", false);
Run Code Online (Sandbox Code Playgroud)
下面是将视频编码为不同输出集的示例代码:
_workingDirectory = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath;
var sourceMp4 = "cat1.mp4";
var destinationPathAndFilename = System.IO.Path.Combine (_workingDirectory, "cat1_out.mp4");
var destinationPathAndFilename2 = System.IO.Path.Combine (_workingDirectory, "cat1_out2.mp4");
var destinationPathAndFilename4 = System.IO.Path.Combine (_workingDirectory, "cat1_out4.wav");
if (File.Exists (destinationPathAndFilename))
File.Delete (destinationPathAndFilename);
CreateSampleFile(Resource.Raw.cat1, _workingDirectory, sourceMp4);
var ffmpeg = new FFMpeg (this, _workingDirectory);
var sourceClip = new Clip (System.IO.Path.Combine(_workingDirectory, sourceMp4));
var result = ffmpeg.GetInfo (sourceClip);
var br = System.Environment.NewLine;
// There are callbacks based on Standard Output and Standard Error when ffmpeg binary …Run Code Online (Sandbox Code Playgroud) 我的android项目中有一个recyclerview,它在每个视图中显示媒体内容.我想要实现的是,当我向上和向下滚动时,我能够播放/暂停媒体.我需要获得完全可见视图的适配器位置.我正在做这样的事情.
在我的活动片段中我有这个:
layoutmanager = new LinearLayoutManager(Activity);
adapter = new FeedAdapter(vid, userName, this.Context);
feeditem.SetLayoutManager(layoutmanager);
feeditem.SetAdapter(adapter);
var onScrollListener = new XamarinRecyclerViewOnScrollListener(Activity, layoutmanager, adapter);
Run Code Online (Sandbox Code Playgroud)
滚动侦听器事件如下所示:
public override void OnScrollStateChanged(RecyclerView recyclerView, int newState)
{
base.OnScrollStateChanged(recyclerView, newState);
if (newState == (int)ScrollState.Idle)
{
layoutmanager = (LinearLayoutManager)recyclerView.GetLayoutManager();
int firstVisiblePosition = layoutmanager.FindFirstCompletelyVisibleItemPosition();
int visible = layoutmanager.FindFirstVisibleItemPosition();
int last = layoutmanager.FindLastVisibleItemPosition();
if (firstVisiblePosition >= 0)
{
if (oldFocusedLayout != null)
{
Toast.MakeText(ctx, "Stop Video", ToastLength.Long).Show();
}
}
currentFocusedLayout = layoutmanager.FindViewByPosition(firstVisiblePosition);
Toast.MakeText(ctx, "Play video", ToastLength.Long).Show();
oldFocusedLayout = currentFocusedLayout;
}
} …Run Code Online (Sandbox Code Playgroud) 我已经阅读了许多文章和教程,演示了如何使用Azure移动服务,但是我不清楚许多事情.
我有一个使用Azure SQL数据库的现有Web应用程序,并随Azure一起发布.我正在尝试将已创建的数据库集成到我正在开发的Xamarin Android应用程序中.
我对以下事情感到困惑.
我是否需要更改.Net后端才能使用Xamarin应用程序中的数据库表?我看到它的方式,我不应该需要,因为Xamarin应用程序与SQL数据库通信,而不是.Net应用程序.
如何将数据存储到SQL表中?我只是在我的Xamarin应用程序中引用移动服务,它将在SQL数据库和我的应用程序之间建立一个桥梁,还是我需要首先创建表格或从数据库导入现有的表格?
Web应用程序当前已部署到Azure Web服务.是否需要部署到移动应用服务?
如果有人可以帮我解决这些问题,我将非常感激.
当我运行以下ExecuteStoreQuery时,会立即抛出InvalidOperationException并显示以下消息:
执行命令时,参数必须是数据库参数或值.
SqlParameter param1 = new SqlParameter("@pNetworkHealthAssessmentID", pNetworkHealthAssessmentID);
SqlParameter param2 = new SqlParameter("@pRiskAssessmentQuestionsID", pRiskAssessmentQuestionsID);
SqlParameter param3 = new SqlParameter("@pUserID", UserID);
SqlParameter param4 = new SqlParameter("@pSortOrder", pSortOrder);
var result = db.Database.ExecuteSqlCommand("sp_RiskAssessmentQuestion_Copy2Network @pNetworkHealthAssessmentID, @pRiskAssessmentQuestionsID, @pUserID", "@pSortOrder",
param1, param2, param3, param4)
Run Code Online (Sandbox Code Playgroud)
存储过程的参数如下所示:
CREATE PROCEDURE [dbo].[sp_RiskAssessmentQuestion_Copy2Network] (
@pNetworkHealthAssessmentID bigint
,@pRiskAssessmentQuestionsID bigint
,@pUserID bigint
,@pSortOrder int
)
Run Code Online (Sandbox Code Playgroud)
存储过程不会返回任何值.为什么我得到那个例外?我已经尝试了所有可能的解决方案但到目前为止都没有成功
当我运行使用 sequelize 库连接 MSSQL 数据库的节点应用程序时,出现此错误。
我已经尝试在本地和全局手动安装繁琐,但错误仍然存在。
完整的错误堆栈如下:
Error: Please install tedious package manually
at new ConnectionManager (D:\medibookr-api\node_modules\sequelize\lib\dialects\mssql\connection-manager.js:27:15)
at new MssqlDialect (D:\medibookr-api\node_modules\sequelize\lib\dialects\mssql\index.js:14:30)
at new Sequelize (D:\medibookr-api\node_modules\sequelize\lib\sequelize.js:239:20)
at Object.<anonymous> (D:\medibookr-api\models\index.js:30:17)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (D:\medibookr-api\repositories\users.js:4:16)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (D:\medibookr-api\routes\middleware\authenticated.js:3:25)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at …Run Code Online (Sandbox Code Playgroud) 当我尝试将新实体添加到数据库中时,出现此错误。实体名称为DestuffedContainer. 该实体及相关实体的定义如下:
去填充容器:
[Table("DestuffedContainer")]
public class DestuffedContainer
{
public long DestuffedContainerId { get; set; }
public int Index { get; set; }
public string Description { get; set; }
public int? PackageQuantity { get; set; }
public string PackageType { get; set; }
public double? CBM { get; set; }
public string Location { get; set; }
public string MarksAndNumber { get; set; }
public int? ManifestWeight { get; set; }
public int? FoundWeight { get; set; } …Run Code Online (Sandbox Code Playgroud) 我有一个基于 .Net 的后端服务器,它托管在 Azure 上。我正在尝试使用 Xamarin 构建一个 android 应用程序。该应用程序将具有聊天功能,允许用户相互交流。我一直将 SignalR 用于简单的实时 Web 任务,我知道使用 Google Cloud Messaging for android 可以实现大部分相同的功能,但是我读到 SignalR 比 Google Cloud 更可靠。我更喜欢使用谷歌云消息服务,因为它不需要与后端持续连接,因此可以节省电池时间。但我唯一的困境是我是否能够实现网络聊天。这个想法是将 SignalR 用于 Web,将 Google Cloud Messaging 用于 android。我需要确保两个聊天同步。有可能这样做吗?或者我应该同时使用 SignalR 吗?任何帮助表示赞赏!
android ×3
asp.net-mvc ×2
c# ×2
xamarin ×2
.net ×1
asp.net ×1
asp.net-core ×1
entity-framework-core-migrations ×1
ffmpeg ×1
node.js ×1
sequelize.js ×1
signalr ×1
sql ×1
tedious ×1
video ×1