.net-4.0

Why can't my .NET 4.5 project use a DLL compiled for .NET 4? (Both use EF 5)

≯℡__Kan透↙ 提交于 2019-12-13 05:19:33
问题 I have an application that consists of a client-side application and a WebApi website. My client-side stuff is targetting .NET 4 so that I don't have to insist that users install .NET 4.5. My website, however, is entirely under my control, so I'm targetting .NET 4.5. There is one shared assembly, which I use for data access. It uses Entity Framework 5. When I build the client application, the DLL used is version 4.4.xxx, whereas when I build the web application, the DLL is 5.0.xxx. Up until

How to generate Visual Studio Project using T4 using XML?

北战南征 提交于 2019-12-13 05:18:51
问题 Hi all! In earlier days it is possible using Code-Dom , I came to know that using T4 is much easier than Code-Dom. I have gone through many articles but still I am not in a situation to draft-out the code which will meet my requirements. I need to generate a code on the basis of an auto-generated XML document [ I am able to generate the XML document as per my requirements ]. It seems like this : <?xml version="1.0" encoding="utf-8" ?> <GeneratedSolution Name ="name of Solution">

checking if a postscript font is installed

痞子三分冷 提交于 2019-12-13 04:37:39
问题 I need a way to check if a specific postscript font is installed on a users computer. I have found many ways to check for true type fonts but none seem to work for post script. I have found checking C:\windows\fonts to be unreliable as sometimes the postscript font file is in that directory but not actually installed and available to programs. All the computers are running windows 7 64bit and I'm using c# .net 4.0 回答1: So I found two ways of checking this. the first is probably the most

Wait for other transaction to commit/rollback before beginning another transaction?

∥☆過路亽.° 提交于 2019-12-13 04:30:05
问题 How can I make my transactions to wait if there is still an un-committed/un-roll-backed transaction in MySQL? Currently I do my transactions on the code side, not on the DB Stored Procedure side, like this: cmd.Connection.BeginTransaction(); try { // db codes here cmd.Transaction.Commit(); } catch { cmd.Transaction.Rollback(); throw; } finally { cmd.Connection.Close(); } I want for other transactions to wait until the previous transaction is finished. Since I have, in some of my stored proc,

Most efficient/right practice to trim the meaningless zeroes at the end of a decimal

﹥>﹥吖頭↗ 提交于 2019-12-13 04:19:58
问题 This is so many times repeated at SO, but I would want to state my question explicitly. How is a decimal which would look like 2.0100 "rightly" presented to the user as another "decimal" 2.01? I see a lot of questions on SO where the input is a string "2.0100" and need a decimal 2.01 out of it and questions where they need decimal 2.0100 to be represented as string "2.01". All this can be achieved by basic string.Trim, decimal.Parse etc. And these are some of the approaches followed: decimal

Put SqlDataReader data into a DataTable while i process it

一个人想着一个人 提交于 2019-12-13 04:19:09
问题 I want to query a database and with the results, i want to process them. While im processing them, some of them will need to be inserted into another database. Since i cannot run another query with an open SqlDataReader (that i know of). I was thinking about putting the data from the SqlDataReader into a DataTable while i process it. Is there a built in way to do this or is there another solution that can accomplish the same idea? 回答1: SqlDataReader reader = com.ExecuteReader(); DataTable dt

How to know when any method is called in my application code?

你离开我真会死。 提交于 2019-12-13 04:06:18
问题 Just for fun, I want to write an aspect such as say logging, tracing or instrumentation/profiling. But I don't want to use any of the available AOP frameworks already available. I've used PostSharp in the past and now that ASP.NET MVC introduces action filters, which are very similar to aspect/advise injection, and .NET 4 has CodeContracts, which are also very similar to aspects, I have a pretty good idea of what I want my aspect API to look like. The only thing I haven't figured out yet, and

Refreshing the Items in an XMLDataSource bound ASP.NET ListView

心不动则不痛 提交于 2019-12-13 03:59:25
问题 I have a ASP.NET ListView control on a page and it is bound to an XMLDataSource. When i change the data in the DataSource, the onItemDataBound event of the ListView is called, and the ListViewItemEventArgs object contains the items that were bound to the listview the very first time. I am unable to refresh the content of the listview. This persists even after I leave the page and come back later. Considering its a fresh page_Load, i can't understand why the ListView still contains old data.

I'm getting “'Eval' is not declared. It may be inaccessible due to its protection level” in a ascx

筅森魡賤 提交于 2019-12-13 03:38:25
问题 I have an ascx that uses Eval in a repeater like this: <%@ Control Language="VB" AutoEventWireup="false" CodeFile="Similar.ascx.vb" Inherits="x.y.z.Similar" %> <asp:repeater runat="server" id="rptAlternatives" visible="false" Enableviewstate="false"> <HeaderTemplate> <section id="similar" class="sidelist sideModule"> <h3>Possible Alternatives:</h3> <ul class="sideborder"> </HeaderTemplate> <ItemTemplate> <li> <a href="/bar/<%# Eval("URL")%>" class="box">foo</a> </li> </ItemTemplate>

Fastest way to count folder files in .NET 4.0

自古美人都是妖i 提交于 2019-12-13 03:05:10
问题 I need to count the number of files in a folder in .NET 4: The count will return number of all files except the .db file in the folder. Option 1: IEnumerable<string> enumerables = Directory.EnumerateFiles(strPath, "*.*", SearchOption.TopDirectoryOnly); int iNumFiles = 0; foreach (string f in enumerables) { if (!f.EndsWith(".db")) iNumFiles++; } //iNumFiles is the count Option 2: int iNumFiles = 0; IEnumerable<string> enumerables1 = Directory.EnumerateFiles(strPath, "*.*", SearchOption