.net-4.0

why does (sender,e) => SomeAction() works on winforms and not in asp.net

假如想象 提交于 2019-12-24 19:01:43
问题 I have the following code: btnTest.Click += (sender,e) => SomeAction() why does this code works in WinForms and not in asp.net. In asp.net I had to do the following: btnTest.Click += new EventHandler(SomeAction); target framework in both cases is .net 4.0 回答1: Is it possible you are trying to call btnTest.Click += (sender,e) => SomeAction() from inside the Page_Load method or another event handler? In that case the parameters "sender" and "e" are already declared and can be causing a conflict

Going from dev to prod with .net Membership Provider

六眼飞鱼酱① 提交于 2019-12-24 17:52:28
问题 I use SQLExpress on my dev machine. I just posted my application to a new prod server with SQL Server installed on it... I have restored my SQL DB in prod and i am successfully connecting to the DB with my connection string. However, the membership provider seems to be failing to find my users in the DB. Am i missing a step to configure or "activate" the membership provide on the prod server? Any help would be great. Thank you. 回答1: I have a strong feeling it has to do with the

Can I add a DependencyProperty on an windows user control?

吃可爱长大的小学妹 提交于 2019-12-24 17:37:21
问题 I'm trying to host a Visio ActiveX object in a WPF application. To do this, I created a Windows user control project where I add the Visio object. This windows user control is then hosted on an WPF user control in an WindowsFormsHost object. <WindowsFormsHost Name="wfHost" Grid.Row="1"> <wf:VisioUserControl FileNamePath="?"/> </WindowsFormsHost> What I would like to do is to bind the value of the FileNamePath member to the value of a TextBox element which defines the path. The project follows

Error when creating an instance of Word in VB.net

こ雲淡風輕ζ 提交于 2019-12-24 17:27:15
问题 I am getting an error when I run this app in VS 2010 (it works fine in VS 2008) Private Sub GenerateInvoice() Dim emptyObject As Object = System.Reflection.Missing.Value Dim wordApp As New Word.Application wordApp.Visible = True Dim InvoiceDoc As New Word.Document InvoiceDoc = wordApp.Documents.Add(InvoicePath, emptyObject, emptyObject, emptyObject) Dim totalFields As Integer = 0 For Each mergeField As Word.Field In InvoiceDoc.Fields The error occurs at the For Each line "Object reference not

Serializing data using XmlArrayItemAttribute not working well

时间秒杀一切 提交于 2019-12-24 17:02:08
问题 I have this DataContract, which is an array of strings: [System.Xml.Serialization.XmlArrayAttribute(Order = 19)] [System.Xml.Serialization.XmlArrayItemAttribute("CardNumber", typeof(string), IsNullable = false)] [DataMember] public string[] Cards {get; set; } As I read, it should be serialized like this: <Cards> <CardNumber>123123</CardNumber> </Cards> but I'm still getting: <Cards> <string>123123</string> </Cards> What's wrong with it? 回答1: You can use CollectionDataContract instead. First,

Threaded application issue

别等时光非礼了梦想. 提交于 2019-12-24 17:00:02
问题 Ive got an issue where the first item in the collection is responding to an update but no others (out of 40). Ive had a look around the net for answers but unfortunately Im still getting nowhere after a couple of days. The calling code which kicks off a thread for the detection loop: _detectionThread = new Thread(() => _x.StartDetection()); _detectionThread.Start(); Ive got the following code in one of my helper classes which simply polls and when something is detected, by way of an event the

URL Rewriting .NET 4 not working?

≯℡__Kan透↙ 提交于 2019-12-24 16:46:05
问题 I have been trying the most basic examples of URL rewriting in .net 4 and can nothing to work locally or on an IIS server? This is my global.asax file <%@ Application Language="C#" %> <script runat="server"> void Application_Start(object sender, EventArgs e) { // Code that runs on application startup RegisterRoutes(System.Web.Routing.RouteTable.Routes); } public static void RegisterRoutes(System.Web.Routing.RouteCollection routeCollection) { routeCollection.MapPageRoute("RouteForCustomer",

BigInteger.ToString() returns more than 50 decimal digits

本秂侑毒 提交于 2019-12-24 16:22:49
问题 I'm using .NET 4 System.Numerics.BigInteger Structure and I'm getting results different from the documentation. In the documentation of BigInteger.ToString() Method It says: The ToString() method supports 50 decimal digits of precision. That is, if the BigInteger value has more than 50 digits, only the 50 most significant digits are preserved in the output string; all other digits are replaced with zeros. I have some code that takes a 60 decimal digits BigInteger and converts it to a string .

IEnumerable reports compiler error when used with the namespace System.Collections

倾然丶 夕夏残阳落幕 提交于 2019-12-24 16:04:58
问题 I was looking at this Squares extension method which was already there in Internet. I could not get this compiling. The compiler reports something like, "The non-generic type `System.Collections.IEnumerable' cannot be used with the type arguments" . any ideas what is wrong with this code below ? any help is much appreciated. using System.IO; using System; using System.Collections; static class Program { static IEnumerable<int> Squares (this int from, int to) { for (int i=from;i<=to;i++) {

WCF Custom ServiceBehavior/InstanceProvider with parameterless constructor

99封情书 提交于 2019-12-24 15:45:52
问题 We're trying to use Dependency Injection for a WCF Service. The Service has a dependency on a Unity Container. The container is used to find the appropriate class that implements an IJob Interface (based on a JobKey parameter in the method call) and calls a method on it. The Service is being hosted in MVC2. I've omitted as much irrelevant stuff as possible from the snippets below. Full code available if required... What I've done so far: Based on this MSDN Article, I've created a custom