c#-4.0

Which one is correct approach for assembly reference in csproj file?

久未见 提交于 2020-01-03 17:20:54
问题 In my one of the MSI Installer I am updating the assembly and project reference relative path pro-grammatically.My all reference assemblies inside my application folder. I try to implement both the path relative and absolute path. Both are working fine. Relative Path <Reference Include="log4net"> <HintPath>..\..\..\..\log4net.dll</HintPath> </Reference> Absolute path <Reference Include="log4net"> <HintPath>C:\Program files\Myapplication\log4net.dll</HintPath> </Reference> I have only seen

How to specify ApplicationName in NpgSql connection string

梦想与她 提交于 2020-01-03 17:15:14
问题 Is it possible to to specify ApplicationName in NpgSql connection string? The following resource usually helps, but it says nothing in this case: Npgsql connection strings 回答1: ApplicationName works for me - "Server=localhost;Port=5432;User Id=***;Password=***;Database=***;ApplicationName=test" . 回答2: In case there are people who searched for answer to this question, here is the solution: application_name=MyApp will not work for npgsql version 2.2.4.3 (Latest Released 2015-02-05) Change

What's the memory footprint of the DLR?

百般思念 提交于 2020-01-03 15:20:10
问题 I'm considering making limited use of C#'s dynamic keyword. My initial time trials were astonishing - a performance hit of less than a second for 100,000 iterations (likely due to DLR caching). I don't have access to a memory profiler, though, and Eric Lippert wrote: Then it starts up the DLR [...] The DLR then starts up a special version of the C# compiler... What's the memory footprint of this, and is it unloaded when the dynamic code is garbage-collected? 回答1: is it unloaded when the

Use OLEDB to read AccessFile from Stream to DataSet

☆樱花仙子☆ 提交于 2020-01-03 15:16:30
问题 I Use Oledb to read an AccessFile(.accdb) to DataSet, I don't know about table names or columns, The regular implementation is: public void GetAccessDB(string filepath){ this.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source = " + filepath; // get Table Names this.TableNames = new List<string>(); using (System.Data.OleDb.OleDbConnection oledbConnection = new System.Data.OleDb.OleDbConnection(this.ConnectionString)) { oledbConnection.Open(); System.Data.DataTable dt = null; dt

EF Core execute sql

孤者浪人 提交于 2020-01-03 13:35:26
问题 Am testing out Entity Framework Core, it's been well so far until i hit an error. I am not able to execute sql from a DbSet with FromSql. Error is dbset does not contain a definition for 'FromSql' The code is _context.Account.FromSql("Select * from dbo.Account"); What am i doing wrong? 回答1: It happened that I needed one more nuget package to get FromSql as well as Include to work. I added this to my dependencies in the project.json file and after the restore, Voila. "Microsoft

How to remove wpf grid sort arrow after clearing sort descriptions

一个人想着一个人 提交于 2020-01-03 13:20:11
问题 I click on a grid header to sort a column and then click a "Reset" button to clear the sort descriptions through its collection view. But the sort arrow icon still persists in the header. How to remove it? 回答1: simple solution i can think of is foreach (DataGridColumn column in DataGridView.Columns) { column.SortDirection = null; } 回答2: I came across this question whilst trying to work out how to clear the sort from the grid completely. Thanks to [krishnaaditya] for the answering how to clear

Switching top-most form without flickering

假如想象 提交于 2020-01-03 13:03:19
问题 I'm developing a magnifier in C# .NET (using WindowsForm) that shows a top-most click-able through form. This top-most window shows an specific part of the screen. The problem I'm having is that to take the screenshot I need to Hide() and Show() the form (otherwise I would take a screenshot of the magnifier) and this creates an annoying flickering in which the magnifier disappears and rapidly appears again. How could I take a screenshot of the Desktop without hiding/showing the form? Is there

ASP.NET + NUnit : Good unit testing strategy for HttpModule using .NET 4

我只是一个虾纸丫 提交于 2020-01-03 11:37:43
问题 I have the following HttpModule that I wanted to unit test. Problem is I am not allowed to change the access modifiers/static as they need to be as it is. I was wondering what would be the best method to test the following module. I am still pretty new in testing stuff and mainly looking for tips on testing strategy and in general testing HttpModules. Just for clarification, I am just trying to grab each requested URL(only .aspx pages) and checking if the requested url has permission (for

Base class of struct construct in C#

安稳与你 提交于 2020-01-03 11:32:54
问题 http://msdn.microsoft.com/en-us/library/ah19swz4(v=VS.71).aspx As per the above link….. “Structs, however, inherit from the base class Object……” As per the below link http://msdn.microsoft.com/en-us/library/system.valuetype.aspx Struct is implemented after ValueType in the hierarchy. “struct” is derived from which class? Or compiler treats “struct” reserve word to make any declaration using “struct” as value type? Missing the small thread in overall understanding. Thank you for your help.

Base class of struct construct in C#

我是研究僧i 提交于 2020-01-03 11:32:40
问题 http://msdn.microsoft.com/en-us/library/ah19swz4(v=VS.71).aspx As per the above link….. “Structs, however, inherit from the base class Object……” As per the below link http://msdn.microsoft.com/en-us/library/system.valuetype.aspx Struct is implemented after ValueType in the hierarchy. “struct” is derived from which class? Or compiler treats “struct” reserve word to make any declaration using “struct” as value type? Missing the small thread in overall understanding. Thank you for your help.