Tag: .net

YouTube API – 从用户限制中获取所有video?

我正试图通过YouTube的数据API从一位用户那里获取所有video。 但是,我遇到了障碍:它似乎没有返回用户的所有video。 有没有办法提高显示的最大金额? 我用于测试的url是http://gdata.youtube.com/feeds/api/users/GoogleDevelopers/uploads

在Startup.cs .net core 2.1中加载程序集

我有一个名为nuqkgs的文件夹中的块包,在项目启动时我想将这些包(有dll)加载到项目中以便在运行时使用。 我使用以下代码加载它们,当我调试时,我可以看到信息,并且找到并打开了dll,但是当它们应该被使用时,我得到了无法找到dll的错误,我可以看到解决方案尝试在bin文件夹中查找它们(它们位于solution / nuqkgs /) 我不想在任何文件中注册包我只是希望能够将一个块包放入nuqkgs文件夹并自动注册 任何想法或任何人在核心2.1中做到这一点? 这是我的startup.cs: public void ConfigureServices(IServiceCollection services) { services.Configure(options => { options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); IList components = new List(); foreach (string file in Directory.EnumerateFiles(@”C:\Users\myName\source\repos\core2.1test\core2.1test\nuqkgs\”, “*.nupkg”, SearchOption.AllDirectories)) { using (ZipArchive nuget = ZipFile.Open(file, ZipArchiveMode.Read)) { foreach (ZipArchiveEntry entry in nuget.Entries) { if (entry.Name.Contains(“.dll”)) { using […]

如何插入具有自动增量编号作为主键的新记录?

例如,我有以下表格: 顾客信息 cus_id: auto increment, int, is Identity cus_name: nvarchar 如果我使用以下代码插入记录“彼得”, string name = “Peter”; DataContext DC = new DataContext(); CustomerInfo newCustomer = new CustomerInfo(); newCustomer.cus_name = name; DC.CustomerInfos.InsertOnSubmit(newCustomer); DC.SubmitChanges(); 以下错误返回, 无法对“Table(CustomerInfo)”执行“创建”,“更新”或“删除”操作,因为它没有主键。 我是否需要自定义cus_id或任何其他解决方案? 谢谢!

如何从另一个项目中的一个项目调用类?

请原谅这个令人难以置信的愚蠢问题,但我不熟悉C#。 我只是无法弄清楚如何在另一个项目中使用一个项目中的类。 假设我想从Project1到Project2获取一个字符串,并让Project2打印出该字符串。 我使用“添加引用”菜单从Project1引用Project2,然后我添加“使用Project2”然后我将其写入尝试并从“Project2”中的“ClassA”调用“print”。 Project2.ClassA Classa = new Project2.ClassA(); Console.WriteLine(Classa.print); 但我得到的只是错误信息。 所以任何人都可以一步一步解释为什么我需要做什么?

WPF:validation确认密码

我有2个PasswordBoxes。 我需要检查密码是否相等。 我不想将这个条件写入[] .xaml.cs代码,但我想在密码不相等时将PasswordBox标记为红色。 我应该编写特殊的ValidationRule,ViewModel中的一些代码还是别的什么? 谁能帮我? 现在validation写在[] .xaml.cs中,但我想避免它。

C#File.Copy抛出exception“不支持给定路径的格式”

string source = @”C:\Users\damanja\Desktop\Projects\RecStudentManagement\RecStudentManagement.Web\Reports\Templates\ContactInformationReport.xlsx”; string dest = @”C:\Users\damanja\Desktop\Projects\RecStudentManagement\RecStudentManagement.Web\Reports\Ran\damanja2012-12-17T10:14:02.0394885-06:00.xlsx”; File.Copy(source, dest, true); 产生此exception: The given path’s format is not supported. 堆栈跟踪: at System.Security.Util.StringExpressionSet.CanonicalizePath(String path, Boolean needFullPath) at System.Security.Util.StringExpressionSet.CreateListFromExpressions(String[] str, Boolean needFullPath) at System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess access, AccessControlActions control, String[] pathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList) at System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess access, String[] pathList, Boolean checkForDuplicates, Boolean needFullPath) at System.IO.File.InternalCopy(String sourceFileName, […]

尝试发布SQL CLR数据库的日期时间类型不匹配

我试图站起来将一些.net函数发布到SQL Server数据库的旧解决方案。 但是,发布到新数据库的尝试在操作日期的函数上失败。 失败的function是: [SqlFunction(TableDefinition=”localtime datetime2″, IsDeterministic=true, IsPrecise=true, DataAccess=DataAccessKind.None, SystemDataAccess=SystemDataAccessKind.None)] public static DateTime ConvertFromUTC(DateTime utctime, string timezoneid) { if (utctime.Kind == DateTimeKind.Unspecified) utctime = DateTime.SpecifyKind( utctime, DateTimeKind.Utc ); utctime = utctime.ToUniversalTime(); return TimeZoneInfo.ConvertTimeBySystemTimeZoneId( utctime, timezoneid ); } 我尝试发布时收到的错误消息是: 创建[dbo]。[ConvertFromUTC] … (268,1):SQL72014:.Net SqlClient数据提供程序: 消息6551,级别16,状态2,过程ConvertFromUTC,第1行 “ConvertFromUTC”的CREATE FUNCTION失败,因为返回值的T-SQL和CLR类型不匹配。 (268,0):SQL72045:脚本执行错误 从.net生成的SQL,试图添加该函数: CREATE FUNCTION [dbo].[ConvertFromUTC] (@utctime DATETIME, @timezoneid NVARCHAR (MAX)) […]

HttpClient中“服务器返回无效或无法识别的响应”的含义

在等待HttpClient .PostAsync响应时,我有时会看到一条错误,指出“服务器返回了无效或无法识别的响应” : System.Net.Http.HttpRequestException: An error occurred while sending the request. —> System.Net.Http.WinHttpException: The server returned an invalid or unrecognized response at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult() at System.Net.Http.WinHttpHandler.d__105.MoveNext() — End of inner exception stack trace — at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult() at System.Net.Http.HttpClient.d__58.MoveNext() 这是一个非常神秘的错误; 我想我可以设想一个“无效”的响应可能是什么(即语法无效的HTTP响应,比如直接跳转到没有状态行的头部的响应),但实际上是对HTTP的“无法识别的”响应请求? 这条消息似乎是无稽之谈。 在引擎盖下,什么情况下实际上可以触发这个错误?

如何将DataTable序列化为json或xml

我正在尝试将DataTable序列化为Json或XML。 可能吗?怎么样? 请给我任何教程和想法。 例如,有一个sql表: CREATE TABLE [dbo].[dictTable]( [keyValue] [int] IDENTITY(1,1) NOT NULL, [valueValue] [int] NULL, CONSTRAINT [Psd2Id] PRIMARY KEY CLUSTERED ( [keyValue] ASC )WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] C#代码: string connectionString = “server=localhost;database=dbd;uid=**;pwd=**”; SqlConnection mySqlConnection = new SqlConnection(connectionString); string selectString = “SELECT keyValue, valueValue FROM dicTable”; SqlCommand mySqlCommand […]

使用JavaScript在GridView中选择行

我在asp.net中遇到GridView的一些问题, Edit 当我点击编辑链接时,它会显示编辑AJAX弹出面板,但我现在怎样才能点击哪一行? 有解决方案吗 请帮我。