Questions tagged [c#-4.0]

C# 4.0 introduced features like dynamic objects, COM interoperability improvements, generic co- and contra-variance, optional and named parameters. Use this tag if your question specifically pertains to C# 4.0 specific features. The C# tag should be used if your question is not specific to C# 4.0 features.

c#-4.0
Filter by
Sorted by
Tagged with
0 votes
1 answer
10 views

How to compare two Guid List?

I have a Model with a Guid list. public class DetailModel { [Display(ResourceType = typeof(ProductResource), Name = "ProductCode")] public string ProductCode { get; set; } ...
0 votes
0 answers
20 views

Facing error on deploying .Net core site on Google cloud

Deploying .Net core website on google cloud error facing "Unable to read file" Please suggest.
0 votes
1 answer
40 views

I get the Error CS0104 'Assert' is an ambiguous reference between 'NUnit.Framework.Assert' and 'Microsoft.VisualStudio.TestTools.UnitTesting.Assert

I am currently making a simple unit test for my Recipe storage application to test my calorie calculation. However, I keep running into the above issue and am unsure as what I can do to solve it. The ...
0 votes
0 answers
6 views

Responsive Design in WPF c#

I would like to Create a responsive Design in WPF After # a Lot of Searching I havet. find anything can somebody help me. Search everywhere and find nothing. somebody can give some instructions on ...
0 votes
1 answer
3k views

Add a footer to an existing OpenXML spreadsheet

EDIT: There's a further detail I left out with my original post. The program is using a template stream rather than a concrete template for the ".Open" command. The template stream gets initialized ...
1 vote
2 answers
12k views

How to read all the rows of the excel sheet and run in Selenium test script using C#?

I need help reading all the rows from excel sheet as a test data in my selenium test case. I can read only one row of an excel sheet with the following code. //set up test for selenium public void ...
1 vote
1 answer
245 views

Uploading large video file(mp4, 130 megabyte) to YouTube with ResumableUploader

I have following code: var newVideo = new Video { Title = Path.GetFileNameWithoutExtension(file), Keywords = keywordstring, Description = "Some Description" }; newVideo.Tags.Add(...
2 votes
4 answers
2k views

Loading and accessing template variables inside text file

we have a bunch of text templates that are embedded resources in our visual studio solution. I'm using a simple method like this to load them: public string getTemplate() { var ...
0 votes
1 answer
44 views

Cloning an image file when pressing a button in a C# form application

I have an image box in the C# form application and I want to clone that image when I press it.I tried this code but I didn't get any results private void pictureBox9_Click(object sender, EventArgs e) {...
337 votes
21 answers
265k views

Better naming in Tuple classes than "Item1", "Item2"

Is there a way to use a Tuple class, but supply the names of the items in it? For example: public Tuple<int, int, int int> GetOrderRelatedIds() That returns the ids for OrderGroupId, ...
0 votes
0 answers
529 views

When to use with(nolock) and WITH (XLOCK, ROWLOCK, HOLDLOCK)

What is difference between with(nolock) and WITH (XLOCK, ROWLOCK, HOLDLOCK). In My application, I was processing 10000 data using parallel.Foreach library but many times duplicate records inserted....
0 votes
0 answers
13 views

Bouncy Castle C# PemWriter.WriteObjects algorithms

is there a list of working algorithm strings for Org.BouncyCastle.OpenSsl.PemWriter in the method public void WriteObject(object obj, string algorithm, char\[\] password, SecureRandom random)type here ...
0 votes
1 answer
60 views

A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed "

Getting an error while calling API from WCF service: "A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed ...
0 votes
3 answers
2k views

Specflow: Read example table data in BeforeScenario or AfterScenario hook

Consider the below scenario, @regression @msexcel Scenario Outline: Open all supported excel formats from windows explorer Given I navigate to a windows explorer directory named <directoryName> ...
1 vote
2 answers
12k views

asp.net bootstrap Keep current active tab after post-back event

I have the following asp.net aspx code <asp:LinkButton CssClass="form-search" ID="LinkButtonSearch" runat="server">Search</asp:LinkButton> <br /> <ul class="nav nav-tabs" id="...
1 vote
4 answers
24k views

How i can set IDENTITY_INSERT to On [closed]

I am getting the error while to insert values to database table: Cannot insert explicit value for identity column in table 'ref_user' when IDENTITY_INSERT is set to OFF. Please help me out ???
1 vote
2 answers
2k views

Could not find a registry key with name "AspNetMvc4VS11" under "Software\NuGet\Repository"

I am getting the following exception when I try to create a new project by using Durandal template in VS 2013. New-->Project-->Web--> ASP.NET MVC 4 Web Application --> Durandal SPA Project ...
68 votes
5 answers
114k views

Using DataContractSerializer to serialize, but can't deserialize back

I have the following 2 functions: public static string Serialize(object obj) { DataContractSerializer serializer = new DataContractSerializer(obj.GetType()); MemoryStream memoryStream = new ...
29 votes
4 answers
53k views

Multiple App.Config Files in .NET Class library project

I am creating one class library project. Now by default I have one App.Config file so that I am putting all environment specific data in that Config file. Now based on the Environment (whether Dev / ...
0 votes
3 answers
3k views

Adding attachments using url in mail with C sharp

I can send attachments with URLs, But, looking for support to send a file with an attachment. that too should download from url and attach with mail. MailMessage mail = new MailMessage(); mail.From = ...
0 votes
0 answers
34 views

Visual Studio C# SerialPort receiving ASCII convert to normal character

Sorry I'm newbie in C# windows app to serial hardware. I'm having a hard time and already tried all of my possible resources. Problem is I'm receiving ASCII response in a machine using serial. This is ...
0 votes
1 answer
2k views

how to get value from appSettings for given config file using c# winform?

I'm giving .config file path and i want to retrieve appSetting value for key=MYDATA from that given .config file. I tried following code but not getting expected. //System.Configuration....
3 votes
5 answers
28k views

how to create an asp button dynamically and add event to it

I'm trying to create a button dynamically on asp.net,but I can't add the event to it.What is wrong or missing below? Thanks in advance $ Button btn2 = new Button(); btn2.ID = "btnEdit"...
4 votes
3 answers
2k views

Creating BitmapImage throws missing key exception

I have a view that displays an image with it's title and comment alongside it. When I load up existing images I utilize this code: this.ArtifactIdentity = image.ArtifactIdentity; this....
3 votes
6 answers
18k views

To count the frequency of each word

There's a directory with a few text files. How do I count the frequency of each word in each file? A word means a set of characters that can contain the letters, the digits and the underlining ...
147 votes
8 answers
96k views

No Main() in WPF?

I am a beginner when it comes to programming but I was sure that one of the universal rules was that a program starts with Main(). I do not see one when I create a WPF project. Is Main() simply named ...
1 vote
1 answer
915 views

What is the purpose of <asp:templatefield>?

It seems like there is HeaderTemplate and ItemTemplate and EditItemTemplate within the TemplateField at the code which I am examining. What else can exists with <asp:TemplateField> apart from ...
16 votes
4 answers
8k views

Monkey Patching in C#

Is it possible to extend or modify the code of a C# class at runtime? My question specifically revolves around Monkey Patching / Duck Punching or Meta Object Programming (MOP), as it happens in ...
0 votes
0 answers
21 views

The process cannot access the file 'filename' because it is being used by another process solve

The process cannot access the file 'filename' because it is being used by another process [WebMethod(Description = "Work Order Proposal Print", EnableSession = true)] public string ...
1 vote
1 answer
328 views

How to write multiple nested objects in a C# model to a SQL database

I have the following model object in C# that I'm receiving in a WEB API from a POST - Does anyone know how I would write this object to a database? The tables can be whatever, I'm just not sure how to ...
0 votes
0 answers
18 views

How can I get the full content of a Word Document?

I have reviewed several ways to obtain access to the content of a Document in C# but no matter how much I search, I cannot find a way that truly takes all the information within it, so far I can only ...
0 votes
0 answers
44 views

How to translate text in c#?

How can I translate a string in english to spanish in c#? string bio="my name is xyz"; I made a culture to convert the string: string bio = "my name is xyz"; var culture = new ...
0 votes
3 answers
18k views

How do I cast on an update? The data field is set to vchar(4) and I would like to cast it as an int

This is what I have come up with so far but I am getting a syntax error update t_Provider set(CAST(f_Postnr as int)) = '66886' where f_Name= 'Test1'
140 votes
8 answers
140k views

How to change the output name of an executable built by Visual Studio

I want to change name of executable file. Like suppose my project name is "SampleDemo" It will create executable file Like 'SampleDemo.exe' but I want to rename it to 'Demo.exe'
29 votes
2 answers
3k views

Why covariance does not work with generic method

Assume I have interface and class: public interface ITree {} public class Tree : ITree {} As IEnumerable<T> is covariant, the code line below is compiled successfully: IEnumerable<ITree>...
0 votes
0 answers
42 views

Serialization and validation of multiple C# attributes (built-in and Custom) in JSON schema

I required a help on JSON schema and JSON validation where We have a requirement to have multiple attributes (built-in and custom) for a property in C# and then serialize them into JSON schema. I am ...
0 votes
2 answers
619 views

Simple Parallel Tasks with Continuation

I have been reading for the 2 hours and I am still confused. Some say use StartNew, some say Task.Run some say something else. I do know that Task.Run is giving me a compile error. I need to start ...
0 votes
3 answers
18k views

Creating gantt chart in C#

I need a help creating gantt chart, that will look like this below I am using DevExpress 12.2, and WinForms. It doesn't need to be done with DevEpress, I just need to get that look. Thank you
0 votes
0 answers
37 views

How to move photo path from database to image editor in c#?

On the Web Desktop App I print the personnel information in my database into the datagrid. I can bring the required fields dynamically with focusedrowchange. As I bring the information, I want to ...
0 votes
1 answer
342 views

How do I configure a (MVC using entity framework) controller in a web API project

I have a MVC 4.0 Web API project and I have already added the model of my database to it so I have the files: .edmx .Context.tt .context.cs .edmx.diagram I'm trying to figure out how to add a ...
0 votes
1 answer
85 views

can't enter "d" "e" or "f" with sendkeys on Safari 17.3.1

I'm using safaridriver, included with Safari 17.3.1 (19617.2.4.11.12). I'm not having problems with the latest versions of Chrome, Edge or Firefox. I have a web page with just a textarea input. If I ...
1 vote
1 answer
53 views

Quartz scheduler not calling the Job class

I'm pretty new to C# and I was trying to learn about Quartz scheduler. I have been trying to execute the below code but my doubt is why is the scheduler not entering the HelloJob class. Am I doing ...
46 votes
3 answers
22k views

Reset System.Lazy

In a business class I have : class Employee{ public Employee() { m_Manager = new Lazy<Manager>( () => return myRepository.GetManager(ManagerId); ); } public int ...
7 votes
4 answers
4k views

How make XMLDocument do not put spaces on self-closed tags?

I have an XML well formatted without any spaces. It' must be like that. When I load it to XMLDocument to sign, the self-closing tags gets an extra white space and <cEAN/> becomes: &...
0 votes
1 answer
32 views

Retrieve records of recently modified files among duplicates in same folder

Table col1 col1 col3 filepath1 filename1 modified date1 filepath1 filename1 modified date1 filepath1 filename1 modified date2 <- latest in duplicates in col1 filepath1 ...
2 votes
4 answers
6k views

Bind CheckBoxFor to bool?

How to bind nullable bool to checkbox in MVC 2. I try with this code in view: <%: Html.CheckBoxFor(model => model.Communication.Before)%> But show me compilation error. Thanks in advance....
1 vote
3 answers
1k views

Component attributes do not support complex content (mixed C# and markup) error message

I am working on validation on a form in a blazor server application. I created the component below that I am using @* Inherits from the original InputText component *@ @inherits InputText @...
0 votes
0 answers
37 views

How to apply effect inside WPF UIElement OnRender method?

I want to apply a blurr effect to a specific geometry, inside WPF UIElement OnRender method. I have code like below. protected override void OnRender(DrawingContext drawingContext) { ...
0 votes
3 answers
364 views

I can't seem to access a web application externally

I am getting a "Server Unavailable" error message when I try to access a web application externally, but I can access it fine internally. It's got a message for administrators telling me to check the ...
3 votes
1 answer
9k views

Download file using Web API call

I am using Web API to download a file. Let me first preface that this is new territory for me. My download function inside the Web API code will initiate a download if I go directly to the API's ...

1
2 3 4 5
517