.net

Single Instance using Mutex in NET

眉间皱痕 提交于 2021-02-11 12:32:04
问题 How to make vb Form a single instance use Mutex. For the developers! Hi, I searched in the net how to make a single instance startup form in VB Net not in c# code. Here is my solution: In the project select "Add class..." Rename the new class in "NativeMethods.vb" and put this code: Add this reference: Imports System.Runtime.InteropServices Public Const HWND_BROADCAST As Integer = &HFFFF Public Shared ReadOnly WM_SHOWME As Integer = RegisterWindowMessage("WM_SHOWME") <DllImport("user32")>

C# dll method call fails to write and read to/from the registry when called from ASP.NET web page

此生再无相见时 提交于 2021-02-11 12:32:00
问题 I have a class within a dll that has the following methods for writing to the registry: public Boolean WriteDBConnectionInfoToRegistry(string txtDSN, string txtServer, string txtDatabase, string txtUser, string txtPassword, bool trusted) { SymmetricAlgorithm rijn = SymmetricAlgorithm.Create(); rijn.GenerateKey(); rijn.GenerateIV(); Boolean b1 = RegistryWrite("Software\\MyApp", "IV", Reverse(Convert.ToBase64String(rijn.IV))); Boolean b2 = RegistryWrite("Software\\MyApp", "Key", Reverse(Convert

How to show all the threads or instances of excel file in vb dot net.I want to show all the threads and one main process of excel files

落花浮王杯 提交于 2021-02-11 12:22:40
问题 How can I show all the threads or instances of Excel file in vb dot net? I want to show all the threads and one main process of Excel files. I have seen the process and process id but not a way to show all threads of Excel, meaning if I open three Excel files I can show three files in listbox. 回答1: I am not sure there is an easy way to do this. Here is some code that I have modified from a similar situation. Firstly here is a class that gets the child window titles from a specified process id

EF LINQ include nested entities [duplicate]

元气小坏坏 提交于 2021-02-11 12:03:28
问题 This question already has an answer here : Tree stucture table and entity framework (1 answer) Closed 3 years ago . I have multi-leveled entities with the following hierarchy: Parent-> RootChildren -> Children -> Children -> ..... Class Parent { public int Id {get; set;} public virtual Child RootChildren {get; set;} } Class Child { public virtual List<Child> Children {get; set;} } Now, I want to include entity which include all the child as nested way. I tried the following but it didn't work

SQL server - Insert string record containing backslash

左心房为你撑大大i 提交于 2021-02-11 09:52:42
问题 I'm trying to insert a record in the table where one of the column has following value. \\\\a\\b\\c Database DataProvider = new SqlDatabase(connectionstring); DataProvider.ExecuteNonQuery("sprocname", Id, qText, ); Here, qText has above value. After execution, the value gets added in the table as \ (single backslash) only. If I try to insert the record manually in the table, INSERT INTO mytbl(id, q) VALUES (0, '\\\\a\\b\\c') proper value gets inserted. Any reason why this is happening? Am I

Compiling Azure Function v1 (.NET Framework) gives FileNotFoundException for Microsoft.Azure.WebJobs

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-11 09:40:19
问题 I have an Azure Functions v1 project (ala .NET Framework) in Visual Studio 2017. It would build / compile just fine for a long time, now it's giving the following FileNotFoundException complaining it can't find 'Microsoft.Azure.WebJobs' v2.2. The thing it this project was building just fine, then all of a sudden this error is occurring. In the past I would close Visual Studio, then reopen it and the build would work. Or even if you Clean the solution, the build would then work. The problem is

Compiling Azure Function v1 (.NET Framework) gives FileNotFoundException for Microsoft.Azure.WebJobs

情到浓时终转凉″ 提交于 2021-02-11 09:40:01
问题 I have an Azure Functions v1 project (ala .NET Framework) in Visual Studio 2017. It would build / compile just fine for a long time, now it's giving the following FileNotFoundException complaining it can't find 'Microsoft.Azure.WebJobs' v2.2. The thing it this project was building just fine, then all of a sudden this error is occurring. In the past I would close Visual Studio, then reopen it and the build would work. Or even if you Clean the solution, the build would then work. The problem is

roslyn dependenceis MissingMethodException

ε祈祈猫儿з 提交于 2021-02-11 08:32:40
问题 After upgrading the dependencies in project roslyn compiler started to throw missing method exception in the following code that before update worked: CSharpCompilation compilation = CreateCompilation(templateId, syntaxTrees, metadataReferences); EmitResult compileResult; generatedAssembly = string.Empty; using (var stream = new MemoryStream()) { compileResult = compilation.Emit(stream); Now its throwing MissingMethod exception: System.MissingMethodException Method not found: 'System

roslyn dependenceis MissingMethodException

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-11 08:31:48
问题 After upgrading the dependencies in project roslyn compiler started to throw missing method exception in the following code that before update worked: CSharpCompilation compilation = CreateCompilation(templateId, syntaxTrees, metadataReferences); EmitResult compileResult; generatedAssembly = string.Empty; using (var stream = new MemoryStream()) { compileResult = compilation.Emit(stream); Now its throwing MissingMethod exception: System.MissingMethodException Method not found: 'System

Violation of PRIMARY KEY constraint 'PK_XY'. Cannot insert duplicate key in object 'dbo.XY'

自作多情 提交于 2021-02-11 08:23:44
问题 Using EF Core, I have a Zone that can have multiple Sol (soils), same Sol can be attached to multiple Zone : public class Sol { // ... public ICollection<Zone> Zones { get; set; } = new List<Zone>(); } public class Zone { // ... public ICollection<Sol> Sols { get; set; } = new List<Sol>(); } public override void Configure(EntityTypeBuilder<Zone> builder) { // ... builder .HasMany(p => p.Sols) .WithMany(p => p.Zones); } When adding my Sols to a Zone however I get the following exception: