Questions tagged [c#-4.0]

0

votes
1

answer
19

Views

Read value from xml element which tag name contains colon (:) in c#

I extracted body data from soapResponse which is given by webservice. but am not able to extract from tags which contains colon between and below data is the body response. XML Sample Data: 123456789 Abhinav used below c# code for about to get values are 123456789 and Abhinav, but it returns empty...
lucky
1

votes
1

answer
2.8k

Views

ImageSourceConverter - System.NullReferenceException

I'm trying to load an external XML file that contains references to images in WPF. I'm parsing the XML and using the following code to convert each path attribute to an ImageSource. string backgroundString = (string)backgroundNode.Attributes["path"].Value; Debug.WriteLine(backgroundString); //return...
jaeta
0

votes
1

answer
6

Views

Can a _Layout.cshtml have a controller

I want to add navigation from database in _Layout.cshtml. I've created a controller for this and create _Layout.cshtml as a list view but its not working This is my view code @model IEnumerable @ViewBag.Title - My ASP.NET Application @Styles.Render("~/Content/css") @Scripts.Render("~/bundles/moderni...
Owais Bin Rizwan
1

votes
2

answer
408

Views

What is the advantage of initializing static variable in a static constructor instead of direct assignment of value

In the below-mentioned code, there are two ways of assigning the value of the static variable 'RateOfInterest'. By directly assigning the value. By assigning in a static constructor. I believe for multiple objects of the 'Customer' class, 'RateOfInterest' will have only one memory allocation using e...
Koder101
1

votes
3

answer
160

Views

How can I get total number of devices and total number of messages send to azure IoT hub c#

we only have these two methods available for azure IoThub in c#. Device device = await registryManager.GetDeviceAsync("deviceId"); and device = await registryManager.GetDevicesAsync("max count"); but how to get all available device count or active device count and also a messages count using c#?
Neo
1

votes
1

answer
1.1k

Views

Set startup page in Windows 8 application

I create new project for Windows Store (C#) from template Split App (XAML) and I want to change Startup page from ItemsPage.xaml to SplitPage.xaml. How can I do that?
GIone hok
1

votes
1

answer
1.7k

Views

C++/CLI Interface is not visible from my C# Class

I have an interface in C++/CLI I need to implement in C#, but I it is not visible. However I have other classes (abstract and concrete that I can inherit from). My C++/CLI Interface: namespace MyNamespace { namespace MySubnamespace { public interface class ITestInterface { public: property bool Fir...
Dzyann
1

votes
2

answer
2k

Views

ILMerge: Combining assemblies in one exe, App.Config

I am using ILMerge to combine .ddls in one executable, however when I run the Output.exe, it seems not to be finding the App.Config file. It is returning an error of: InvalidOperationException: No connection string name could be found in application config file. I wonder whether ILMerge has included...
t_plusplus
1

votes
1

answer
2.3k

Views

MVC async without waiting on task to complete

I make an ajax request to invoke a controller action like so: Controller: [AsyncTimeout(8000, Order = 3)] [HandleError(ExceptionType = typeof(TimeoutException), Order = 4, View = "TimeoutError")] public async Task RemovePackageAsync(CancellationToken cancellationToken, string packageId, ICollection...
ShaneKm
1

votes
3

answer
856

Views

Deserializing date string in DD/MM/YYYY hh:mm:ss.fff format from XML

My program receives data from a device in XML. The device returns date times as a string in DD/MM/YYYY hh:mm:ss.fff format. How do I deserialize this into a DateTime object, even though the local machine is set up for the US English culture?
Tony Vitabile
1

votes
1

answer
2.4k

Views

Check if ALL elements in 2D-Array have same value

if we have a 1D array, we could use the following to see if all elements are equal to 3: int[] t = Enumerable.Repeat(3, 10).ToArray(); if (t.All(item => item.Equals(3))) MessageBox.Show("all elements equals to 3"); but if I have a 2D-array, how could I check if all elements are equal to 3 ( without...
farzin parsa
1

votes
1

answer
1.7k

Views

Returning List<string> from XDocument

Template name Template1 Template2 XDocument xml = new XDocument(); xml = XDocument.Parse(xmlstringFromAbove); List list = (from c in xml.Elements("data") select c.Value).ToList(); This code returns an empty list. How can I get a list of strings containing Template1 and Template2 ?
simon831
1

votes
1

answer
97

Views

Can we directly work on Umbraco 4.9.0 Source file(from codeplex) to develop a website Which i opened it using visual studio 2010

I already have Umbraco 4.9.0 in my Server so i don't need the source to open installation page. I need to open my default page directly and launch my site. The problem doing that is every-time when i run the source. It goes too install umbraco i want it too directly open my default page.can it be do...
Karthikeyan.T
1

votes
3

answer
514

Views

Error Adding To HashSet From Multiple Threads

I'm trying to add to a hash set from multiple threads. If the item already exists I want to update it, if it doesn't exist I want to add it to the list. With the code I'm using I am ending up with lots of duplicates, I presume because multiple items are suddenly pointing to the same reference. I c...
Oli
1

votes
5

answer
140

Views

C# arranging string variables in some container

I am new to C# i have these many string values in my code as string text1 = textbox1.text; string text2 = textbox2.text; string text3 = textbox3.text; string text4 = textbox4.text; and some bool values as well bool chk1 = checkBox1.Checked; bool chk2 = checkBox2.Checked; bool chk3 = checkBox3.Checke...
user1838130
1

votes
2

answer
377

Views

Map List<List<string>> into List<Dictionary<string, int>>

I'm trying the following code to map a list of lists into list of dictionaries but I'm getting error index out of range Updated the question List _terms = new List(); for (int i = 0; i < _numcats; ++i) { _terms.Add( GenerateTerms(_docs[i])); } // where _docs[i] is an array element // and the proce...
FSm
1

votes
1

answer
242

Views

Unable to return IEnumerable<TEnum> in place of IEnumerable<T>

I wrote this EnumHelper method public static IEnumerable AsEnumerable(Func projection = null) where TEnum : struct { if (!typeof(TEnum).IsEnum) throw new InvalidOperationException("Type parameter TEnum must be an enum"); if (projection == null) return Enum.GetValues(typeof (TEnum)).OfType(); return...
Nasmi Sabeer
1

votes
2

answer
2.2k

Views

Tortoise svn client hook script from command line

Do you know if there exist a command to create a client hook script for TortoiseSVN? I need to create the hook from C# code, not from GUI. I looked for command at the following page, but there is no information about hook scripts.
Rafael Enriquez
1

votes
2

answer
1.5k

Views

Searching Text Against a List Using Regex?

I have a block of text: We the People of the United States, in Order to form a more perfect Union, establish Justice, insure domestic Tranquility, provide for the common defence, promote the general Welfare, and secure the Blessings of Liberty to ourselves and our Posterity, do ordain and establish...
Mark
1

votes
3

answer
2.9k

Views

C# how to resize images and save them with maximum possible quality - batch job [duplicate]

Possible Duplicate: How to Resize Image and save in folder? I would like to resize and save as images in a given folder. But i want to do it with maximum possible quality. I am willing to use third party software. Like paint.net or photoshop. So what is the best possible way of achieving this ? Th...
MonsterMMORPG
1

votes
2

answer
631

Views

Setting alias name for the gridview field

My table having a field fld_status. It hold the values 0 and 1. 0 means active ,1 means inactive. But i want to show the meaning full name like active for 0 in the Gridview. Is there is any way to change this value 0 and 1 meaningful name in Gridview other than query? In gridview STATUS column show...
user1804985
1

votes
3

answer
3.4k

Views

How to import contacts from gmail,hotmail,yahoo,facebook etc in asp.net?

I want to import contacts from gmail,yahoo,hotmail,facebook etc in asp.net? Please help me how to import contact in asp.net. sir I want to import all email contacts not only gmail. so please tell me soln...
Jitendra singh
1

votes
1

answer
307

Views

GC and unmanaged code in C# / C++

I have a silly question. If I have an array in C++, that I am using to store a number of references (I'm guessing IntPtrs, haven't gotten that far yet) to various C# objects, how does the GC in C# know not to collect these objects? I mean, the mark and sweep algorithm can't see into the unmanaged co...
user978122
1

votes
1

answer
623

Views

Ldap user authentication not working for locked or disabled account

I am working on a website to manage ldap. I am stuck in a situation, when I am trying to authenticate user with account locked or disabled it fails. What I want to do is first authenticate user after that show message that account locked or disabled. I am coding like this LdapConnection connection...
mayank.karki
1

votes
2

answer
1k

Views

Entity Framework code first in data access layer

I am using N-layer architecure in my project. In the data access layer I use Entity Framework code first. When I fill an object in the DAL, dispose the context and transfer the object to the business layer, the navigation properties become null. I have no problem if I don't dispose the context, but...
Mohsen
1

votes
3

answer
1.4k

Views

File size - actual number of bytes used on disk (not allocated) [duplicate]

Possible Duplicate: Get Size of file on disk Is there a way to retrieve the actual number of bytes used for a particular file on disk, using C# / windows? My application implements "watch" folders, similar to FileSystemWatcher. Some watch folders exist on shared storage (both network and fibre chan...
James Heliker
1

votes
1

answer
238

Views

Looping a sound is not working in C#

i have added a piece of code to have a *wav file looped in my Visual C# 2010 express edition Project game (i ve added wav file in content folder project as well in debug folder) , but it plays only 1 time till end then it stops. the code i ve added is these : SoundEffect sound; sound = Content.Load(...
Enrico Griggio
1

votes
2

answer
80

Views

Find / Count Redundant Records in a List<T>

I am looking for a way to identify duplicate records...only I want / expect to see them. So the records aren't duplicated completely but the unique fields I am unconcerned with at this point. I just want to see if they have made X# payments of the exact same amount, via the exact same card, to the e...
GPGVM
1

votes
3

answer
187

Views

Pattern / architecture / anonymous methods

I am relatively new to C#, maybe you could help me with this. I got a couple of methods callServiceXY(param1, param2, ...) that call a certain service. For many reasons these service calls can go wrong (and I don't really care for the reason in the end). So basically I need to always wrap them with...
Alex
1

votes
2

answer
212

Views

MVC: View with remote hosted layout

So, our client wants to embed our MVC applicaiton in their site. First solution on my mind - load our application in a iFrame on their site, and we are done. Turns out what they want is a bit more complex (and imo stupid). We must still host our application, but when a user comes to our site, it mus...
Yevgen Trush
1

votes
1

answer
1.5k

Views

Outlook Add-in: Fetch attendees email address of selected meeting

I am developing a small Outlook add-in which will fetch all information about selected meeting and push this information to our in-house portal. Implementation is complete except RequiredAttendees part. Not sure why, but Interop.Outlook.AppointmentItem object is only returning full names (as string)...
Firoz Ansari
1

votes
2

answer
1.8k

Views

Azure Storage - CloudBlob.UploadFile - how do I verify upload succeeded?

I am writing automatic tests and I need to check if the Upload succeeded. How do I do that? How come there is no FileExist method?
Nizar Blond
1

votes
1

answer
481

Views

HTMLAgilityPack node name filter doesn't work

I want to get the text of a page using HTMLAgilityPack. I have some code for this: HtmlAgilityPack.HtmlWeb TheWebLoader = new HtmlWeb(); HtmlAgilityPack.HtmlDocument TheDocument = TheWebLoader.Load(textBox1.Text); List TagsToRemove = new List() { "script", "style", "link", "br", "hr" }; var Strings...
ahmadali shafiee
1

votes
4

answer
1k

Views

WCF Service VS ASP.NET Web Api for Quiz Application [duplicate]

Possible Duplicate: WCF Service or Web API Hi guys i am developing a quiz engine application, I want to create a service that can be accessible from different client platforms e.g android, PHP, Iphone, IPad, Java e.tc. Between WCF and Asp.net web API which you think best suits the scenario? Thanks
1

votes
2

answer
273

Views

Cannot propagate AspNetSynchronizationContext to TPL task

I've read a number of articles that in order to preserve HttpContext.Current in versions prior to 4.5, we should pass on handling thread's SynchornizationContext. Here is a code I am attempting to execute: TaskScheduler taskScheduler = TaskScheduler.FromCurrentSynchronizationContext(); Task.Factory....
Roman
1

votes
2

answer
1.7k

Views

Selecting item from dropdownlist dynamically

I want to select an item dynamically from a database into a dropdownlist. I can set value property of the dropdownlist but I am not able to set the item property, why so? My database has text stored in it so I have to select the item from dropdownlist. adding code of comment string strGetBooking = t...
DharaPPatel
1

votes
1

answer
1.1k

Views

What is the practical difference between dynamic and T in C#

I read about Type dynamic in C# 2010. (the corresponding msdn entry) I am confused about the practical difference between T and dynamic while developing generic functions. My current tests didn't show new ways to use dynamica way, that isn't possible with T. In addition it seems, that dynamic needs...
Dennis Alexander
1

votes
1

answer
4.9k

Views

JsonConvert.SerializeObject() fails in serializing class with DateTime fields

I'm having a class with only private fields and their public getter-setters. I need to convert class object into JSON String hence I'm using JSON.Net. Following is a simple snippet to convert class object into a JSON string. MyClass obj = new MyClass(); string json = JsonConvert.SerializeObject(obj)...
Kushal
1

votes
1

answer
1.2k

Views

Using ManualResetEvent to check if service has finished processing

I have a web service which I need to ensure will finish processing then exit when onstop() is called. Currently when onstop() is called the service immediately stops. I've been told to look at ManualResetEvent and a requeststop flag. I've looked everywhere for examples even found a few of these: How...
user1270384
1

votes
2

answer
405

Views

Cast IWebdriver mock object to IJavaScriptExecutor

How to convert IWebdriver mock object to IJavaScriptExecutor? My code: private Mock _mockBrowserDriver; _mockBrowserDriver = new Mock(); var jsExecutor = (IJavaScriptExecutor) _mockBrowserDriver; Outcome: Unable to cast object of type 'Castle.Proxies.IWebDriverProxy' to type 'OpenQA.Selenium.IJavaS...
Amar HR

View additional questions