.net-4.0

Using uniqueidentifier SQL column type with Entity framework

五迷三道 提交于 2019-12-18 13:35:19
问题 For my primary key and identity in our Clients table I use uniqueidentifier column with a default value set to newsequentialid(). Inserting new rows through the management tool creates the values for the ID fine. Inserting from .NET 4 code via EF results into zero GUIDs (00000-0000....) being inserted. I create the entity with new, set some values and perform EF AddToClients (for instance). If debugged, value for the id property shows zero GUID. I do not explicitly set the id via the Guid

Add Ellipsis to a Path in a WinForms Program without Win32 API call (revisited)

北战南征 提交于 2019-12-18 13:34:42
问题 I was searching for a way to insert an ellipsis in a C# path, and found an answer here on stackoverflow: C# Path Ellipsis without Win32 API call Using the RTM versions of VS2010 and .Net 4.0, I was unable to get the suggested method to work. I searched the 'Net and found example code that uses the same method, but it failed in the same way. You can see the string I'm trying to shorten in my code below. After calling the MeasureText method, both the input string (OriginalName) and the output

Getting cell-backgroundcolor in Excel with Open XML 2.0

蹲街弑〆低调 提交于 2019-12-18 13:29:57
问题 I am trying to get the backgroundcolor of a cell in a excel-spreadsheet. I am using Open XML 2.0 SDK and I am able to open the *.xlsx-file and to get cell-values for example. My code for getting the Background-Color is the following: public BackgroundColor GetCellBackColor(Cell theCell, SpreadsheetDocument document) { BackgroundColor backGroundColor = null; WorkbookStylesPart styles = SpreadsheetReader.GetWorkbookStyles(document); int cellStyleIndex = (int)theCell.StyleIndex.Value; CellFormat

Binding to a double with StringFormat on a TextBox

有些话、适合烂在心里 提交于 2019-12-18 13:28:59
问题 I am using WPF's TextBox with a binding on the Text property to a double on my ViewModel. My XAML looks like this: <TextBox Text="{Binding Path=MyDoubleValue, StringFormat=N2, UpdateSourceTrigger=PropertyChanged}" /> Unfortunately when I switch UpdateSourceTrigger to PropertyChanged and type value 12345 , I get 12,354.00 ( EDIT : notice the 5 before the 4). This is a result of keeping cursor in the same place after adding , between 2 and 3 by the .NET formatter. How can I use StringFormat

Using CurrentDomain.SetData(“APP_CONFIG_FILE”) doesn't work in PowerShell ISE

吃可爱长大的小学妹 提交于 2019-12-18 13:24:12
问题 I'm attempting to use a .NET 4.0 assembly in PowerShell ISE, and trying to change the config file which is used via: [System.AppDomain]::CurrentDomain.SetData("APP_CONFIG_FILE", $PathToConfig); [Configuration.ConfigurationManager]::ConnectionStrings.Count always returns "1", and "[Configuration.ConfigurationManager]::ConnectionStrings[0].Name" always returns "LocalSqlServer", and that ConnectionString name is not in my ".config" file. Note that executing the PowerShell script from a

How to I resolve GetFrameContext failed in Windbg

孤人 提交于 2019-12-18 13:01:33
问题 I'm debugging a .NET 4.0 web application using a full crash dump and Windbg. I seem able to get all the versions of everything to match up however when I try to get the managed stack trace of all the thread I get OS Thread Id: 0x7cd4 (13) Child SP IP Call Site GetFrameContext failed: 1 For all of my managed threads. Any ideas what I'm doing wrong and how I can fix it? 回答1: I was also getting this error, but I noticed that running !DumpStack does give me a trace when !ClrStack does not.

Is this expected C# 4.0 Tuple equality behavior?

≯℡__Kan透↙ 提交于 2019-12-18 12:55:54
问题 I'm seeing different behavior between using .Equals and == between two of .NET 4.0's new Tuple<> instances. If I have overridden Equals on the object in the Tuple<> and call .Equals on the Tuples the override of Equals will be called. If I use == on the Tuples the override of Equals is not called. Is that by design and does it make sense? EDIT: From answers and comments I can tell I'm not being clear. I know Tuple<> is a reference type and that for reference types == will check identity

System.ServiceModel.Activation.HttpModule error

给你一囗甜甜゛ 提交于 2019-12-18 12:33:16
问题 what is the cause of this error on below line? <system.web> <globalization fileEncoding="utf-8" requestEncoding="utf-8" responseEncoding="utf-8" culture="fa-IR" uiCulture="fa-IR" /> <compilation targetFramework="4.0" debug="true"> <assemblies> <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> 回答1: This happens when you install .Net 4 before enabling IIS, or if you register WCF after registering .Net 4. In either case, your App Pools will

Is it possible to trigger a click event from another form?

不打扰是莪最后的温柔 提交于 2019-12-18 12:25:22
问题 I need to run the code of a button that is on another form. is it possible to do it from a different form? if you say that it is possible by declaring it public then: how do i declare a control public? how do i pass the correct events into button_click ? it takes two parameters - how do i pass them,? 回答1: It's possible to make a control in a Form public , but not recommended, you can do the following: 1) Declare a new event in the first form (form1) ButtonFirstFormClicked public event

Illegal characters in path when loading a string with XDocument

半腔热情 提交于 2019-12-18 12:05:52
问题 I have very simple XML in a string that I'm trying to load via XDocument so that I can use LINQ to XML: var xmlString = @"<?xml version=""1.0"" encoding=""utf-8"" standalone=""yes""?> <person>Test Person</person>"; var doc = XDocument.Load(xmlString); //'Illegal characters in path' error thrown here I get an Illegal characters in path. error thrown when I try to load the XML; could someone please explain why this is happening? Thanks. 回答1: You are looking for XDocument.Parse - XDocument.Load