text
stringlengths
46
37.3k
title
stringlengths
12
162
C_sharp : During switching to the new .NET Core 3 's IAsynsDisposable , I 've stumbled upon the following problem.The core of the problem : if DisposeAsync throws an exception , this exception hides any exceptions thrown inside await using-block.What is getting caught is the AsyncDispose-exception if it 's thrown , and...
Proper way to deal with exceptions in AsyncDispose
C_sharp : I have been chasing this issue for a day now and am stumped , so thought I would put it out to you folks for some inspiration . I 'm a bit of a novice when it comes to deadlocks and SQL Server lock modes , I rarely need to delve into this.The short story : When a user logs into our application , we want to up...
Deadlocks during logon to ASP app caused by dropping/creating SQL Server views
C_sharp : I have the following code attaching event handler : Can I unsubscribe that lambda expression from the vent ? <code> this.btnOK.Click += ( s , e ) = > { MessageBox.Show ( `` test '' ) ; } ;
Unsubscribe lambda expression from event c #
C_sharp : Would appreciate any kind of help here . A brief description about scenario -There is a COM+ running on server ( written in C # ) . The task of this COM is to take a file name , page number of a multi-paged tiff file and the resolution to convert it to a gif file image . This COM is called from a web applicat...
Possibly memory leak OR ?
C_sharp : I researched this subject but I could n't find any duplicate . I am wondering why you can use a struct in an array without creating an instance of it.For example , I have a class and a struct : When ClassAPI is used in an array , it has to be initialized with the new keyword before being able to use its prope...
Why does n't a struct in an array have to be initialized ?
C_sharp : I reviewed a colleagues code and told him to reorder the boolean comparisons in the following Linq Any predicate for performance reasons . So givenandI suggested changing the following : to becomeMy reasoning was that most of the jobs in jobsList fail the test for JobType , only a few will fail the test for R...
Order of evaluation c #
C_sharp : I was reading this page , which is officially referenced in the release notes of Visual Studio 17 RC , it states the following : For the purpose of Overloading Overriding Hiding , tuples of the same types and lengths as well as their underlying ValueTuple types are considered equivalent . All other difference...
Overriding Methods with Tuples and Field Name Rules in C # 7.0
C_sharp : I 'm trying to implement a search function in a custom ListView and as such I am hiding Items with a custom ObservableCollection which allows AddRange , similar to the one defined on damonpayne.com ( for the tl ; dr-ers out there basically it suppresses firing OnCollectionChanged event while adding multiple i...
ListViewItem 's group not being preserved through another collection
C_sharp : I 've been trying to shift myself into a more test driven methodology when writing my .net MVC based app . I 'm doing all my dependency injection using constructor-based injection . Thus far it 's going well , but I 've found myself doing something repeatedly and I 'm wondering if there is a better practice o...
Unit tests break when I add new dependency to controller
C_sharp : I was debugging resource leaks in my application and created a test app to test GDI object leaks . In OnPaint I create new icons and new bitmaps without disposing them . After that I check the increase of GDi objects in task manager for each of the cases . However , if I keep repainting the main window of my ...
Is there a difference in disposing Icon and Bitmap ?
C_sharp : I am really confused , take the following code : And yes I know that I could directly cast the integer to the given Enum , but this is a simplified version of my actual code which includes the work with generic extensions.Anyhow I ran a few performance tests , because I was curious which one is faster . I am ...
Why is casting with dynamic faster than with object
C_sharp : How can I change items in my double variable based on a simple condition ? Check this example : After executing the function setDouble ( ) , these values did n't change . No errors found . How can I fix this ? <code> public partial class Form1 : Form { double [ ] vk = new double [ 11 ] { 0 , 0 , 0 , 0 , 0 , 0...
How can I change items inside a double array ?
C_sharp : My company is on a Unit Testing kick , and I 'm having a little trouble with refactoring Service Layer code . Here is an example of some code I wrote : In this simplified case ( it is reduced from a 1,000 line class that has 1 public method and ~30 private ones ) , my boss says I should be able to test my Cal...
Refactoring Service Layer classes
C_sharp : I have an object called Page , with an instance called p that has a custom property called AssociatedAttributes . If I do the following : numMatchingAttributes ends up equaling 0 even though p has 6 AssociatedAttributes . Why does it not equal 6 ? AssociatedAttributes is of Type List < Attribute > ( Attribute...
Can someone explain LINQ 's intersect properly to me ? I do n't understand why this does n't work
C_sharp : Do the following 2 code snippets achieve the same thing ? My original code : What ReSharper thought was a better idea : I think the above code is much easier to read , any compelling reason to change it ? Would it execute faster , and most importantly , will the code do the exact same thing ? Also if you look...
Are these 2 statements identical ?
C_sharp : I have a sorted array of strings.Given a string that identifies a prefix , I perform two binary searches to find the first and last positions in the array that contain words that start with that prefix : Running this code I get firstPosition and lastPosition both equal to 1 , while the right answer is to have...
Why ( `` abc '' +char.MaxValue ) .CompareTo ( `` abc '' ) ==0 ?
C_sharp : I have a list of objects that looks like this : now , I 'd like to browse ( traverse ) it with a for each . But I want to traverse it starting from the same ID . So , first a foreach for the single/unique ID ( 2000 , 3000 , 4000 , so 3 steps ) . Than , for each `` ID '' step , each Title/Description : so 2 st...
How can I traverse this list in this manner ?
C_sharp : Is calling Array.Resize on an array that is being used as a buffer for SAEA threadsafe ? different threads all write to their own assigned part of the array , I just want to make the array bigger without locking once the initialized size runs out as connected users increase . <code> byte [ ] buffer ; //Access...
Is Array.Resize ( .. ) threadsafe ?
C_sharp : I need to be able to say something like myString.IndexOf ( c = > ! Char.IsDigit ( c ) ) , but I ca n't find any such method in the .NET framework . Did I miss something ? The following works , but rolling my own seems a little tedious here : <code> using System ; class Program { static void Main ( ) { string ...
Is there a String.IndexOf that takes a predicate ?
C_sharp : I have a base class : And a class which stores the DomainEventSubscriber references : Even though the Subscribe method type is constrained , I can not convert from DomainEventSubscriber < T > subscriber where T : DomainEvent to DomainEventSubscriber < DomainEvent > : How would I go about performing this conve...
Convert generic parameter with 'where ' type constraint not possible ?
C_sharp : I created a SqlDependency so that an event would fire when the results of a particular query change.When this code executes , a stored procedure is automatically created with a name like SqlQueryNotificationStoredProcedure-82ae1b92-21c5-46ae-a2a1-511c4f849f76This procedure is unencrypted , which violates requ...
Encrypt the stored procedure created by SqlDependency
C_sharp : Visual Studio C # compiler warns about accidentally assigning a variable to itself , but this warning does not apply to C # properties , only variables . As described in this other question.However , I would really like something similar that can warn me at compile time if I assign a property to itself.I 'm c...
Compile-time detection of accidentally assign a C # property to itself
C_sharp : Here 's a bit of a tricky one . Perhaps someone 's C # -fu is superior to mine , as I could n't find a solution.I have a method that takes a parameter that holds either an enum or a string indicating the value of an Enum and returns an instance of that enum . It 's basically an implementation of Enum.Parse bu...
Is there any way to combine these two methods into one method , or overloaded methods ?
C_sharp : It is conventional to name namespaces in a C # solution such that they match the default namespace for the project plus the name of any sub-directories for the containing file.For example , a file called Haddock.cs is in a directory called Fish and the default namespace ( in the first tab of the project 's pr...
Can an analyzer validate that namespaces properly match the file location
C_sharp : I 'm looking to retrieve the last row of a table by the table 's ID column . What I am currently using works : Is there any way to get the same result with more efficient speed ? <code> var x = db.MyTable.OrderByDescending ( d = > d.ID ) .FirstOrDefault ( ) ;
What 's the most efficient way to get only the final row of a SQL table using EF4 ?
C_sharp : I 'm writing a small data structures library in C # , and I 'm running into an architectural problem . Essentially I have a class which implements the visitor pattern , and there are many possible implementations of visitors : Anytime I want to pass in a visitor , I have to create a visitor class , implement ...
How do I simulate anonymous classes in C #
C_sharp : I am trying to create text that looks like this in WPF : Notice that it is yellow text , with a black stroke , then a yellow stroke , then another ( very thin ) black stroke . Now , I can create a single stroke with little difficult by following How to : Create Outlined Text . Note that the properties not sho...
How do you create multiple strokes on text in WPF ?
C_sharp : I have a set of classes with the same functions but with different logic . However , each class function can return a number of objects . It is safe to set the return type as the interface ? Each class ( all using the same interface ) is doing this with different business logic.Are there any pitfalls with uni...
Is it advisable to have an interface as the return type ?
C_sharp : Which one is better to use ? ORint xyz= default ( int ) ; <code> int xyz = 0 ;
Which one is better to use and why in c #
C_sharp : I have a file that looks something like this : I need to break the file up into multiple files based on the first 6 characters starting in position 2.File 1 named 29923c.asc : File 2 named 47422K.asc : File 3 named 9875D.asc : I do n't know what will be in the file before the program gets it , just the format...
C # Text File Input Multi-File Output
C_sharp : For those who are not sure what is meant by 'constrained non-determinism ' I recommend Mark Seeman 's post.The essence of the idea is the test having deterministic values only for data affecting SUT behavior . Not 'relevant ' data can be to some extent 'random'.I like this approach . The more data is abstract...
Detecting 'dead ' tests and hardcoded data vs constrained non-determinism
C_sharp : can anyone explain why the TextBlock inside my DataTemplate does not apply the style defined in my UserControl.Resources element , but the second TextBlock ( 'Test B ' ) does ? I think it may have to do with a dependency property somewhere set to not inherit , but I ca n't be sure . <code> < UserControl.Resou...
No Style Inheritance Inside ItemsControl / DataTemplate in WPF ?
C_sharp : I am trying to get into C # generics and have created a state machine with the state pattern and now I try to refactor.I have a state , which has a reference to the object it 's working on.and I have the object which has states , this should have a reference to its current state.But it does not work ( `` the ...
C # generics , cross referencing classes for state pattern
C_sharp : Consider the following attribute.When I try to use the attribute [ Nice ( Stuff = `` test '' ) ] the compiler gives the following error . 'Stuff ' is not a valid named attribute argument . Named attribute arguments must be fields which are not readonly , static , or const , or read-write properties which are ...
Why do properties of attributes have to be readable ?
C_sharp : I 'm working my way through this ASP MVC tutorial . This page of the tutorial deals with writing a simple `` search '' page . The controller contains this method : According to MSDN , String.Contains is case-sensitive . But when I navigate to [ website url ] /Movies/SearchIndex ? searchString=mel , it returns...
Why is String.Contains case-insensitive in this query ?
C_sharp : I have a Json string : I 'm using James Newton-King 's Json.NET parser and calling : Where my classes are defined as follows : This all works , but the original list might have different JackFactions rather than B , P , N and H. Ideally what I 'd like to get is : Without changing the Json string , how can I g...
Deserialize Json when number of objects is unknown
C_sharp : I am trying to create a method for ( at runtime ) creating wrappers for delegates of all types . This to create a flexible way of injecting additional logging ( in this case ) . In this first step i tried to create a try-catch wrap around the given input-argument.I am using a generic method call CreateWrapper...
`` variable `` of type 'System.Boolean ' referenced from scope `` , but it is not defined '' in Expression
C_sharp : I know this code does not work ( and have no problems writing it in a way that will work ) . I was wondering how the compiler can build with out any errors . And you get run time errors if you where to run it ? ( assuming data was not null ) <code> using System ; using System.Collections.Generic ; public clas...
Why is the C # compiler happy with double IEnumerable < T > and foreach T ?
C_sharp : I 'm doing a component to format a list , it is an Extension , I wrote the following code , but , when in execution time , it gives me the error : Can not convert lambda expression to type 'System.Web.WebPages.HelperResult ' because it is not a delegate typeThis is the extension : View calling : I already tri...
Expression of HelperResult to format item from a list
C_sharp : I have a collection of nullable ints . Why does compiler allows to iteration variable be of type int not int ? ? Of course I should pay attention to what I iterate through but it would be nice if compiler reprimanded me : ) Like here : <code> List < int ? > nullableInts = new List < int ? > { 1,2,3 , null } ;...
Iteration variable of different type than collection ?
C_sharp : After all the fuss about non-generic classes being obsolete ( well almost ) why are .NET collection classes still non-generic ? For instance , Control.ControlCollection does n't implement IList < T > but only IList , or FormCollection implements only upto ICollection and not ICollection < T > . Everytime I ha...
Why are collections classes in .NET not generic ?
C_sharp : How flexible is DataBinding in WPF ? I am new to WPF and would like to have a clear idea . Can I Bind a string variable with a Slider value ? Does it always have to be a control ? Is it at all possible to bind a string value with a Slider control so that it updates in real time ? How far up the Logical tree d...
How flexible is DataBinding in WPF ?
C_sharp : I am trying to convert a 10,000 by 10,000 int array to double array with the following method ( I found in this website ) and the way I call isit gives me this error , The machine has 32GB RAM , OS is MAC OS 10.6.8 <code> public double [ , ] intarraytodoublearray ( int [ , ] val ) { int rows= val.GetLength ( ...
intArray to doubleArray , Out Of Memory Exception C #
C_sharp : I am using ArangoDB and I am querying a collection named movies . Its data structure is such that categories is a List of strings . Here is the query statement : id is passed as a param and I need to retrieve all the movies that has the category matched by the id.However , above code does n't work as result g...
Linq List Contains
C_sharp : I 'm having an issue trying to create indexes on RavenDB 3.5When creating more than 3 indexes the application just dies , getting a Unable to connect to the remote server Status Code : ConnectFailureThe index creation code is farely straight forward : But the same happens if the IndexCreation.CreateIndexes ( ...
Task Canceled exception on RavenDB when creating indexes
C_sharp : Unfortunatly , i ca n't find the original project which led me to this question . That would have perhaps given this question a bit more context.EDIT : I found the original project i 've seen this in : http : //mews.codeplex.com/SourceControl/changeset/view/63120 # 1054567 with a concrete implementation at : ...
Abstract class inheriting the most derived type
C_sharp : I have been using javascript and I made a lot of use of functions inside of functions . I tried this in C # but it seems they do n't exist . If I have the following : How can I code a method d ( ) that can only be calledfrom inside the method the method abc ( ) ? <code> public abc ( ) { }
Does C # have a concept of methods inside of methods ?
C_sharp : The following Delphi program calls method upon nil reference and runs fine . However , in a structurally similar C # program , System.NullReferenceException will be raised , which seems to be the right thing to do.Because TObject.Free uses such style , it seems to be `` supported '' to call method on nil refe...
Is it `` supported '' to call method on nil reference in Delphi ?
C_sharp : In wpf , I have a textbox , the content of it coming from a txt file.in code behine it looks like : The thing is that the txt file content is changing during the runtime , is it possible to be synchronized with those changes ? I mean that the textbox content would be change if the txt file is changed . if It ...
Update textbox from txt file during runtime without clicking `` refresh ''
C_sharp : It is important to me that my syntax does not make other developers confused.In this example , I need to know if a parameter is a certain type . I have hit this before ; what 's the most elegant , clear approach to test `` not is '' ? Method 1 : Method 2 : Method 3 : Method 4 : [ EDIT ] Method 5 : Which is th...
Best `` not is '' syntax in C #
C_sharp : I 'm trying to debug a crash that happens in our application during garbage collection and looking at the code I found two related pieces of code that , if not the cause of the problem , are at least suspicious to me : Note that from my understanding the struct is actually at least 98 bytes in size but is dec...
Can this code cause a managed heap corruption ?
C_sharp : After reading this question ASP.NET MVC : Nesting ViewModels within each other , antipattern or no ? and Derick Bailey 's comment i think the `` consider what your viewmodel would look like as xml or json '' bit is probably the most important point , here . i often use that perspective to help me understand w...
Do SelectLists belong in viewModels ?
C_sharp : I understand how to get the names of parameters passed to a method , but let 's say I have a method declaration as follows : and I want to use object/property names in my template for substitution with real property values in any of the objects in my ` objects ' parameter . Let 's then say I call this method ...
How can I pass a variable number of named parameters to a method ?
C_sharp : I have this code : The variable p is always null . How is this posible ? Here is a print screen of what I am talking about : I also try with immediate windows I got this : p CAN NOT BE NULL since im creating a new instance of it while all of its properties are not null . I tried clean the project , restart wi...
new operator returning null - C #
C_sharp : I 'm attempting to convert the following method ( simplified example ) to be asynchronous , as the cacheMissResolver call may be expensive in terms of time ( database lookup , network call ) : There are plenty of materials on-line about consuming async methods , but the advice I have found on producing them s...
Correct way to convert method to async in C # ?
C_sharp : I just started using mock objects ( using Java 's mockito ) in my tests recently . Needless to say , they simplified the set-up part of the tests , and along with Dependency Injection , I would argue it made the code even more robust.However , I have found myself tripping in testing against implementation rat...
Use of Mocks in Tests
C_sharp : The requirement used to be that the window is CenterScreen but the client has recently asked that the window is now slightly to the right of its current position.The current definition of the window is : I was hoping that doing the following would work : But the window is still in the same position when it ap...
Is it possible to offset the window position by a value when WindowStartupLocation= '' CenterScreen '' ?
C_sharp : I add a MenuStrip to my form and I would like to add other controls below it like usual Point ( 0 , 0 ) is the top left corner of empty form space . After I add the menu to my form and add more controls they overlap each other . So I want to take away some height of the client rect for the menu and a button w...
How to take away vertical space for programmatically added menu ?
C_sharp : Given that all controls in a WebForm are destroyed ( by my understanding ) at the end of each postback do you need to `` unwire '' any event handlers you may have wired up ? ( Assuming you want to stop handling the events and allow GC ) So for example : <code> public partial class WebForm1 : System.Web.UI.Pag...
Do you need to `` unwire '' event handlers in ASP.NET webforms
C_sharp : In .NET Thread class has static method Yield.I see that method in coreclr implementation of Thread.But documentation does n't contain that Method description.Also .NET CLI ( dotnet build ) cant compile code with that method invocation.Why ? updruntime : 1.0.0-rc1-update1 coreclr x64 darwin project.jsonupd2I '...
Thread.Yield ( ) in coreclr
C_sharp : I want to do the followingHowever I ca n't because you ca n't have static abstract members.I understand why I ca n't do this - any recommendations for a design that will achieve much the same result ? ( For clarity - I am trying to provide a library with an abstract base class but the concrete versions MUST i...
C # class design - what can I use instead of `` static abstract '' ?
C_sharp : i was wondering if there is a way to restrict a value in construction . Here is my code : and when i make a new Student i want to restrict the Grade between > = 2.00 and < = 6.00 , like compile error or excepion on runtime . Is there a way ? ( Do n't worry about other fields FirstName , and LastName ) <code> ...
Constructor restrictions
C_sharp : Sometimes when using the miniprofiler , there 's just some requests that you does n't care about . In my case I do n't care much about signalr , umbraco pings , and some requests made when I wan na know if the user is idle or not.To avoid the miniprofiler using energy on ( and providing results for ) these ty...
How to remove specific URL 's from profiling when using MiniProfiler
C_sharp : I have the following code in my C # application.ReSharper 7.1.1 is highlighting the fact that the DateTimeFormatInfo.CurrentInfo could cause a null reference exception.Under what circumstances would this occur ? Or is this just a mistake on ReSharper 's part believing that any object whose property you access...
How can DateTimeFormatInfo.CurrentInfo be null
C_sharp : I think this looks like a bug in the C # compiler.Consider this code ( inside a method ) : It compiles with no errors ( or warnings ) . Seems like a bug . When run , prints 0 on console.Then without the const , the code : When this is run , it correctly results in an OverflowException being thrown.The C # Lan...
Why does the compiler evaluate remainder MinValue % -1 different than runtime ?
C_sharp : I 'm currently migrating a Windows Azure application to Amazon AWS . In Windows Azure we used Lokad.Clout to get strongly typed access to Azure Blob Storage . For instance like this : For more detailed examples see their wiki.In the AWS SDK for .NET you do n't get strongly typed access . For instance in order...
Strongly typed access to Amazon S3 using C #
C_sharp : I 'm using Rob Conery 's Massive for database access . I want to wrap a transaction around a couple of inserts but the second insert uses the identity returned from the first insert . It 's not obvious to me how to do this in a transaction . Some assistance would be appreciated . <code> var commandList = new ...
Want to use identity returned from insert in subsequent insert in a transaction
C_sharp : My question is different with the one identified . Obviously I have called `` BeginErrorReadLine '' method ( I mark it in the code below ) .I want to parse the result produced by HandleCommand lineWhen run in a command line environment , it will output something like : > handle64 -p [ PID ] Nthandle v4.11 - H...
When run a program in C # , all the messages go to the standard output , but the standard error contains nothing
C_sharp : Is there anyway to know this ? I found one post that asked a very similar question at How to check if an object is nullable ? The answer explains how to determine if an object is nullable if there is access to a Generic Type Parameter . This is accomplished by using Nullabe.GetUnderlyingType ( typeof ( T ) ) ...
How to determine if a non-null object is a Nullable struct ?
C_sharp : Is there a way how to decorate property of datacontract object , so the generated xsd will contain MaxLenght restriction ? E.g . I can imagine I need something like this : and something like this should be included in the output from xsd.exe : Is there a way to do it ? To define the restrictions in C # class ...
How to generate XSD from Class with restrictions
C_sharp : I want to do a foreach loop while taking out members of that foreach loop , but that 's throwing errors . My only idea is to create another list inside of this loop to find which Slices to remove , and loop through the new list to remove items from Pizza . <code> foreach ( var Slice in Pizza ) { if ( Slice.Fl...
Going Through A Foreach When It Can Get Modified ?
C_sharp : Lets say we have the folowing code.What is actually happening ? Cast the obj to a string and then calls the ToString Method ? Calls the ToString method on obj which is the override of string without casting ? Something else ? Witch one is better to do ? var bar = obj.ToString ( ) ; var bar = ( string ) obj ; ...
What happens when calling Object.ToString when the actual type is String
C_sharp : In C # I 've enabled tracing and a net tracing source.But longer messages get truncated ( long like 12Kb/30 lines , not long like 1GB ! ) so I end up in a situation where only part of web reqiest headers are logged.How to fix that ? Or do you know a book or some resource that explains .Net tracing and debuggi...
C # Tracing truncate long messages
C_sharp : This is a very specific problem . Not quite sure how to even word it . Basically I am implementing the unit of work and repository pattern , I have a dynamic object that I convert to an int , but if I use var it will throw an exception when trying to call the method.I tried to remove all the trivial variables...
Casting Dynamic Object and Passing Into UnitOfWork and Repository Pattern . Throws Exception
C_sharp : I 'm building a generic flat file reader which looks something like this.It could be consumed like so.Here are the classes used.Is there a way how I could remove or encapsulate that generic type information in the GenericReader ? I 'm looking for an extra pair of eyes to show me something what I 've been miss...
Can I somehow tidy up this ( overuse ? ) of generics ?
C_sharp : This is my mapping class : This works fine for the Table ( [ mySchema ] . [ MyTable ] ) in my first database.But this table ( `` MyTable '' ) exists in ( actually a lot of ) different databases , but for any reason the schema is always named different ( this I dont have any control of ) : So in the Database `...
Fluent nHibernate : Use the same mapping files for tables with the same structure in different schemas
C_sharp : I 'm using this code to print a PDF file on a local printer with C # within a windows service.Everything works fine when I set a user to run the windows service.Whenever I run this code under the LocalSystem credential , I get the error `` there are no application associated to this operation '' which usually...
PDF Print Through Windows Service with C #
C_sharp : What is the order of implicit conversions done in Console.WriteLine ( x ) when x is an object from user-defined class : Why I get 42 , and not 3.14 or `` 12 '' ? Why I can not add an additional implicit conversion to string /there is Compiler error on the ambiguity between CW ( int ) and CW ( string ) / : I k...
Order of implicit conversions in c #
C_sharp : I am having problems figuring out the Linq syntax for a left outer join within multiple joins . I want to do a left join on RunLogEntry Table so I get records which match from this table as well as all of the Service Entries . Can some one please correct my snytax ? <code> var list = ( from se in db.ServiceEn...
Linq left join syntax correction needed
C_sharp : As a newcomer to TDD I 'm stuggling with writing unit tests that deal with collections . For example at the moment I 'm trying to come up with some test scearios to essentially test the following methodWhere the method should return the index of the first item in the list list that matches the predicate predi...
TDD - writing tests for a method that iterates / works with collections
C_sharp : I have a generic methodThis method is used quite a lot throughout the code , and I want to find where it is used with T being a specific type.I can text-search for but most often the type argument has been omitted from the call ( inferred ) . Is there any way I can find these method invocations in VS2010 or p...
How can I find generic invocations with a specific type argument in my source ?
C_sharp : How do I do that ? And , what do I take on the left side of the assignment expression , assuming this is C # 2.0 . I do n't have the var keyword . <code> sTypeName = ... //do some string stuff here to get the name of the type/*The Assembly.CreateInstance function returns a typeof System.object . I want to typ...
Typecast to a type from just the string representation of the type name
C_sharp : We 're running our Win8 Metro unit tests from powershell using vstest.console.exe , which is included with Visual Studio 2012 . The way the process uses the unit test appx-package created by msbuild , and runs it : \install\location\vstest.console.exe path\to\unittest.appx /InIsolationFrom time to time the ex...
Windows 8 Appx installation timeout during unit test execution
C_sharp : I have written the following SQL CLR function in order to hash string values larger then 8000 bytes ( the limit of input value of the T-SQL built-it HASHBYTES function ) : It is working fine for Latin strings . For example , the following hashes are the same : The issue is it is not working with Cyrillic stri...
SQL CLR function based on .net ComputeHash is not working with Cyrrilic
C_sharp : I understand this is a beta ( just checked the new version of EF 4.3 and it does the same thing ) release and some functionality may be missing , but i haven ` t seen anything to explain why ... ... no longer creates a column of type xml when using EF 4.3 ( column is created as nvarchar ( max ) ) , I have tri...
Entity Framework 4.3 beta [ Column ( TypeName ) ] issue , can not create columns of type xml
C_sharp : Here are two C # classes ... ... and a list of data ( filled somewhere ) ... ... and then this LINQ query : I do not understand the query : What means the `` Any '' function and what does the `` = > '' operator do ? Can someone explain me what 's going on in this code ? Thanks ! <code> public class Address { ...
What does this LINQ query do ?
C_sharp : I feel like I played buzzword bingo with the title . Here 's a concise example of what I 'm asking . Let 's say I have some inheritance hierarchy for some entities.Now let 's say I have a generic interface for a service with a method that uses the base class : I have some concrete implementations : Assume I '...
Mechanism for Dependency Injection to Provide the Most Specific Implementation of a Generic Service Interface
C_sharp : If the data is on a single line the index=int.Parse ( logDataReader.ReadElementContentAsString ( ) ) ; andvalue=double.Parse ( logDataReader.ReadElementContentAsString ( ) , cause the cursor to move forward . If I take those calls out I see it loop 6 times in debug.In the following only 3 < data > are read ( ...
XmlReader behaves different with line breaks
C_sharp : I have a Windows store app that draws an image under the system 's cursor . I capture all the cursor movements using : And this is working fine if I use my mouse to move the cursor.However , I have another application - a desktop application - , that changes the position of the system 's cursor . I 'm using t...
PointerMoved event not firing
C_sharp : So I use Visual Studio 2017 and everything worked ok . But then I updated to 15.6.0 and suddenly nothing is working anymore.All the references like Systme . * or Microsoft . * are with a yellow warning sign ... At every project - even new ones- I keep getting the same type of erros after ( re ) building : I h...
Can not find reference System
C_sharp : I 'm developing an assistive technology application ( in C # ) that overlays information on top of the currently open window . It detects clickable elements , and labels them.To do this , I 'm currently creating a borderless , transparent window with TopMost set to `` true '' , and drawing the labels on that ...
How to draw on top of the right-click menu in .NET/C # ?
C_sharp : Otherwise I always need to check if the value is null before performing any other validations . It 's kinda annoying if I have many custom checks that are using Must ( ) .I placed NotEmpty ( ) at the very top of it therefore it already returns false , is it possible to stop there ? Example <code> RuleFor ( x ...
Is it possible to stop checking further validations when the first one fails ?
C_sharp : I have a partial class using an interface because I can ’ t inherit what was an original abstract class due to the other partial class being auto-generated from Entity Framework 4 and therefore already inheriting ObjectContext.I have the following for my partial class : Here ’ s the interface : And the implem...
Inherited C # Class Losing `` Reference ''
C_sharp : I have several c # structs that give shape to structures in a very large data file . These structs interpret bits in the file 's data words , and convert them to first-class properties . Here is an example of one : I need to do two things , which I think are related . The first is to have the ability to valid...
Auditing and validating changes to C # class and structure properties in a high-performance way
C_sharp : I 've been battling with OAuth and Twitter for 2 weeks now trying to implement it . After many rewrites of my code I 've finally got a library which performs the request as it should be based on the 1.0 spec . I 've verified it by using this verifier on Google Code , and this verifier from Hueniverse.My versi...
Is Twitter implemeting OAuth off spec ? ( C # )
C_sharp : I have an Angular front-end app and an ASP.NET Core back-end app . Everything was fine until I decided to migrate from ASP.NET Core 2.2 to 3.0-preview-9.For example , I have a DTO class : And an example JSON request : Before migration , this was a valid request because 123 was parsed as a decimal . But now , ...
Model binding stopped working after migrating from .NET Core 2.2 to 3.0-preview-9
C_sharp : I wanted to get the projected Balance for the next 12 months from the current month and if the Balance is empty for that month it will get the value from the nearest Month with a Balance of greater than 0.This is what I have tried so far . This would result to : Is it possible to get a result somewhat like th...
How to get the next 12 months with empty months
C_sharp : I have an application that has been working for a while . I tried running it with VS2013 and it hangs on a line where it tries to initialize a DataCacheFactory object . The same code works fine with VS2010 and VS2012.No errors are generated . The code just hangs on the line factory = new DataCacheFactory ( ) ...
AppFabric DataCacheFactory ( ) initialization hangs in VS2013 , works fine in VS2010 and VS2012
C_sharp : I am trying to figure out how to create an asynchronous call from Application_Error Method in MVC.I have an e-mail dll that I have written which sends out an e-mail via asynchronous call using Smtp Client.The problem is that when I call SendEmail method in my dll I have conflict of needing to await for the ca...
Asynchronous call from Application_Error ( )
C_sharp : Browsing some forum I came across this answer in which the answerer refers to the following as the native call stackWhat exactly is the native call stack with regards to the CLR ( here we are looking at the CLR invoking the Main method I think ) and how can I view and come to understand said native call stack...
What exactly is the native call stack with regards to the CLR ?