Questions tagged [c#-4.0]

1

votes
1

answer
48

Views

read xml file having namespace in root

I am trying to get the values of each element from the XML file having namespace in root element but no luck. The xml file looks like I have written some C# code using linq but could not get any result. XDocument xdoc = new XDocument(); var doc = XDocument.Load(fileFullPath); XNamespace ns = 'http:/...
User
1

votes
2

answer
5.5k

Views

Crystal Report Displaying only one row in each page

I am using Crystal Reports with Visual Studio 2012. I am totally new to crystal reports. I just added my data fields to the details section, but instead of showing all the rows in one page, a new page is created for each row. I did not use any grouping or change the section paging settings. Even i c...
Santosh
0

votes
0

answer
6

Views

How to fix “missing an NUnit assembly reference?” error when using SpecFlow

I am new to SpecFlow. I had installed the required NuGet packages for SpecFlow and NUnit. When I had clicked on Build, Visual Studio 2017 is throwing the below errors: 'Error CS0234 The type or namespace name 'TestFixtureTearDownAttribute' does not exist in the namespace 'NUnit.Framework' (are yo...
Abhi3106
1

votes
3

answer
8.2k

Views

How to get server.Mappath in console application c#

How to use server.MapPath in the console application using c#. I tried the below code but I am not getting my pdf file. Kindly suggest in this. string[] pdf_file = System.IO.Directory.GetFiles(@'C:\Folder\' + fileName);
harathi viru
1

votes
3

answer
75

Views

Is -10 between 1.5 × 10^-45 and 3.4 × 10^38?

Is -10 between 1.5e-45 and 3.4e+38? If yes, explain to me why. I am no more that good in Maths. So, sorry for the weakness of these questions level. According to C# documentation (of computer programming for that language) on Microsoft site, their variables float type is between 1.5 × 1e-45 and 3.4...
Cfass King
1

votes
3

answer
1.5k

Views

Resource cannot be found for content inside of theme folders

My project has a feature to override views and content, if they exist, from a themes folder. The path to the themes folder will vary by site, so my folder structure looks like this: Themes\ SiteA\ Content\ Images\ logo.png screen.css Views\ Home\ Index.cshtml I am able to successfully override the d...
Mathachew
1

votes
3

answer
13.5k

Views

How to Convert an ArrayList to string C#

ArrayList arr = new ArrayList(); string abc = What should I do to convert arraylist to a string such as abc = arr;Updated QuestOther consideration from which i can complete my work is concatination of string(need help in that manner ). suppose i have a string s='abcdefghi..'by applying foreach loop...
RollerCosta
1

votes
1

answer
402

Views

Finding <T> in IList<T> using reflection [duplicate]

This question already has an answer here: How to get the type of T from a member of a generic class or method? 17 answers I'm working on a project where I have to reflect through data models to find out what type is in each property on a data models. I have the code working for all cases except fo...
photo_tom
1

votes
0

answer
22

Views

Button type button posting data is not saving in DB

i added on message Box and i am posting that data but not adding in my DB. when i am trying to click Confirm button it is not saving in data-base how it will save to data-base can you please help me. enter image description here var leaveManagement= { leaveData: null, showModal: function(data) { lea...
Dinesh
1

votes
2

answer
66

Views

SqlCommand Error Procedure or function 'X' expects parameter '@Y'

As near as I can tell, this is not a duplicate question because I am supplying an alternative that actually DOES work. VS 2012 targeting .NET 4.5 Common code: public const string SP_PLANT = 'hsp_BOM_EXP_SOURCE'; public const string SP_PARM_PLANT = '@Plant_CD'; public const string SP_PARM_PART_NUM =...
B H
1

votes
0

answer
47

Views

C# JSON Deserialize Dictionary<string, Dictionary<string, string>>

JSON Data: { 'MetaData ': { 'Id': '1', 'CreatedBy': 'Ravi', 'CreatedOn': '06/01/2018', 'State': 'Completed', 'Level': 'Curator' }, 'tbDm': { 'textBox1': 'Ravi', 'textBox2': 'Chaitag', 'textBox3': 'Jp', 'textBox4': 'Ch' }, 'tbCO': { 'textBox5': 'Cha', 'textBox7': 'C', 'textBox8': 'ra', 'textBox6': 'j...
Ravi
1

votes
0

answer
141

Views

Unload dynamic compiled dll

I have a little problem. Frist, I have a program, which has a class for compiling assemblies from scripts that could be written inside this program for using programs data. So I cant unload generated assembly. Tried to use AppDomain.Unload, but it shows that file 'Scripts.DLL' is busy. I wich you co...
1

votes
0

answer
34

Views

How to write a mongodb select query using (in) with C#

In Sql: SELECT * FROM inventory WHERE status in ('A', 'D') MongoDB: db.inventory.find( { status: { $in: [ 'A', 'D' ] } } ) How to write above mentioned query in C# with mongoDB.i am new in mongodb.Please any one help me. Thanks in advance.
Revathi Vijay
1

votes
0

answer
49

Views

How to prevent value can not be Null during c# SQLBulkcopy Processing

I am processing a CSV file using ASP.NET C# and it works if I assign 0 to fields that = ''. But if I try to replace with ' ' or '/t' then I get a value can not be Null when inserting into the database. Here is the C# code in question: while (!csvReader.EndOfData) { var fieldData = csvReader.ReadFiel...
Jason
1

votes
0

answer
19

Views

Extra trailing comma in Header

I have a Cordova application connecting to IIS. I am getting an extra comma when I send: $rootScope.httpConfig = { headers: { 'Content-Type': 'application/json', 'authorization': 'bearer ' + response.Token } }; The token has no commas, somewhere in the pipe between the client and the server a comma...
kroleigh
1

votes
2

answer
131

Views

How to inject only one object to constructor using unity DI

How to inject only one object to constructor using Unity DI. Example: public class MyClass{ public MyClass(ILog logger, IProvider provider, IResolver resolver, ItemTypeEnum itemType) { //.... initializing everything } public ItemTypeEnum ItemType { get; set;} //....methods where I will use this item...
Tomasz M
1

votes
2

answer
86

Views

Using StringComparison.OrdinalIgnoreCase to ignore Case

This code is case sensitive, how to make it case insensitive? return HeaderNames.Length == fileLine.Count && HeaderNames .Select(headItem => fileLine[Array.IndexOf(HeaderNames, headItem)] == headItem) .All(i => i); Thanks for your answers/
Da Ja
1

votes
1

answer
23

Views

Grayed form while loading

i have written the following code in c#. but it didn't the way i want it... my current code opens the 'LoadingForm', but when it shows on screen i can see it as 'gray screen with squares' - instead of the Loading_Gif which i have added to that form, hope you help me (By the way, i tried to run the f...
Ahmad Egbaria
1

votes
0

answer
30

Views

not get record from database to itemcode have spaces although i use ltrim

problem when match item code with item code have spaces by ltrim it get null result Details I make SQL query to get latest prices for customer from database correct result is 13.5 price value but it give me null the problem in item code have spaces IN item code in database so that i dont know how...
user3223372
1

votes
1

answer
843

Views

How to solve this error : must specify valid information for parsing in the string

I want to convert a string to enum . My code is like this var categoryEnum = (SiteCategory) Enum.Parse(typeof (SiteCategory), UIController.QueryStringParamInitialValue, true); And QueryStringParamInitialValue() is like this public static string QueryStringParamInitialValue { get { string str = strin...
ratna
1

votes
1

answer
53

Views

C# search sub directory and files [duplicate]

This question already has an answer here: Getting all file names from a folder using C# [duplicate] 7 answers I need to search a root folder for particular subdirectory named 'XYZ','ABC'. And need to get the filenames from these two folder by iterating these two folder one by one. I have used the b...
Ask_SO
1

votes
1

answer
26

Views

Inspite of checking for null with usercontrol checkboxlist is returning object reference not set to an instance of an object

I have a group of 7 checkboxes in checkboxlist user control. I build a string in the selectedIndexchanged event for the boxes checked, pass to ViewState and then pass ViewState to the Property. I do this because in the instance when no checkboxes are selected I want to handle null. The problem is...
Doreen
1

votes
1

answer
78

Views

C# - Create new URI object to point to a Local file

How can I create a URL object that points to a file that is Local to my web application I thought this would work: var myURI = new Uri('~/Content/css/pdfX.css'); but I am getting this error: Invalid URI: The format of the URI could not be determined. Thanks
Ayo Adesina
1

votes
0

answer
66

Views

Microsoft SQL Server compatibility issue (C# Application)

I am developing a C# application on Windows 10, under Visual Studio 2015. I can see that I have installed on that PC Microsoft SQL Server 2005 Compact Edition, 2012 Native Client, 2014 Express LocalDB, 2016 Local DB and other stuff like this. I did not voluntarily installed any of this, they must ha...
Marko
1

votes
0

answer
196

Views

Add Web Reference with certificates on https

I was adding a web service via 'Add Web Reference' to my project. The web service was only accessible on https with a client certificate.When I did 'Add Web Reference' I got a 'The underlying connection was closed: An unexpected error occurred on a send'. I found an other way to add the web service...
bernova
1

votes
0

answer
216

Views

How to use async in ASP.Net MVC for Mono

I am creating an ASP.Net MVC project in Mono using Visual Studio 2017 for Mac. I added the basic controllers, view, models, etc and it's working fine. However, as soon as make the Index method async I am getting the following error: System.InvalidOperationException The view 'Index' or its master was...
MikePR
1

votes
1

answer
39

Views

how to take checkpoint record and process remaining data from foreach c#

I have multiple files to be process from list. If because of any reason list is interrupted , when next time we execute program it takes the last executed records and start process the further records instead start from 0 index. CamlQuery camlQuery = new CamlQuery(); camlQuery.ViewXml = @' '; camlQ...
Neo
1

votes
0

answer
131

Views

How to get voice stream from Bot client(emulator) using Microsoft Bot framework

I have an issue regarding bot building (Microsoft Bot Framework). The scenario should be like this- for the the first step I need to test on bot emulator(client). The requirement would be to get the voice from client as a stream (as well as need kind of event that can handle is user speaking or not)...
Ariful Islam
1

votes
0

answer
156

Views

Multi-layer perceptron (neural network) - what am i missing?

I am trying to implement my own multi-layer perceptron, unfortunately i make some mistake i can't find. Link to full program is here (it is light, simple c# console application). I am learning from this book , the code I am trying rewrite from batch to sequential form is at this github. Link to my...
Bartek Wójcik
1

votes
1

answer
33

Views

get number from string.format c#

I have use string.format: string strfm = 'PC{0:ddMMyy}.{1:d3}/{2:MM}H' and number : 1 =>string str = string.format('PC{0:ddMMyy}.{1:d3}/{2:MM}H',DateTime.Now,1,DateTime.Now) result str = PC070518.001/05H => str = strfm + number, how to result number{1:d3} from str and strfm, Thank you!
smart duong
1

votes
0

answer
98

Views

ZipFile.CreateFromDirectory C# send to MemoryStream

How would I basically use ZipFile.CreateFromDirectory to send back zipfile to memory stream instead of a output path. Or would I have to use ZipArchive and generate the zip file myself? Seems kind of odd there isn't a method for stream. Here's basically what I'm trying to do using (MemoryStream ms...
jefflahh
1

votes
0

answer
64

Views

Form/Windows/Passport authentication vs Authentication Filter in ASP.NET MVC 5

Why we need Authentication Filters if we already having Form/Windows/Passport Authentication in .NET. 1) Types of authentication in ASP.NET MVC 5 2) Authentication Filters in ASP.NET MVC 5 I'm know both are used to authenticate the user but Why we need both? Can we use both? If Yes, How it will wor...
Raj
1

votes
1

answer
23

Views

Checking whether a unique data is present in a json file

I need to check whether a word is present in a JSON file or not. So if I'm searching for 'root', then even though the word 'byroots' contain root, it should give me false. Here's my code using (StreamReader r = new StreamReader('filename.json')) { string json1 = r.ReadToEnd(); if (json1.Contains('r...
1

votes
1

answer
207

Views

NLog Concurrent Requests into different files

As the title suggests, I am trying to log separate requests to my .NET Web API controllers to separate files. With the introduction of {var}, here is what I am trying inside my c# code. private static Logger logger = LogManager.GetLogger('test'); [HttpPost, Route('xyz')] public IHttpActionResult P...
Sandeep
1

votes
3

answer
476

Views

How to generate a unique string from email or username

I want to create a method in c# that will accept my unique email or username and will return me a unique string just like youtube's video id (https://www.youtube.com/watch?v=_MSYfOYFF14). I can't simply use GUID because I want to generate a unique string against every user and it will remain same fo...
Ask
1

votes
0

answer
52

Views

How long is valid MachineKey encrypted string or no expiry for that

What will be the lifetime for encrypted string using machine key as below: //System.Web.Security MachineKey.Protect(streamarray,purpose); MachineKey.Unprotect(string,purpose); How long protected string is valid. I could not find anywhere that mention, but I believe, its valid and no expiry, is it c...
user3711357
1

votes
0

answer
104

Views

How do I move a AutoGenerate,IsolateApps machine key system onto a load balanced server?

I just found, web.config with below settings in all the environments including prod. Now, application is going to start using with load balancing. Would it create problem as its not using static machine keys ? If I change this key now to static validaitnKey and static decrptionKey then it creates an...
user3711357
1

votes
1

answer
54

Views

Converting hex to int while reading a text file

I have few hex numbers that the last digit mean the length of the string after. for example 2E3F00004Sara 41590000AFavhilmnfr Except from: 515900016Mickael Barrie Linwood Which is 22 not 16.. any idea how to get it from the number? Thank you
Monika
1

votes
1

answer
11

Views

C# Thread Access from Button event

Please kindly help me to add the delay to Continues() method. namespace NetworkUtilities { public partial class Form1 : Form { Thread th1; public Form1() { InitializeComponent(); th1 = new Thread(Continues); } private void Continues() { try { for (int j = 0; j < 4; j++) { Ping myping1 = new Ping();...
1

votes
1

answer
171

Views

How to download pdf file from database using asp gridview link button

I have stored binary data into a db. When I'm fetching and trying to download same pdf file I'm unable to do it. Below is my code snippet: protected void grdDownload_Command(object sender, GridViewCommandEventArgs e) { if (e.CommandName == 'Download') { int index = Convert.ToInt32(e.CommandArgument)...
Gurindapalli

View additional questions