text
stringlengths
46
37.3k
title
stringlengths
12
162
C_sharp : I am rendering some simple text to a PDF in C # using Telerik : This works great locally.I 've set up an Azure app service , and I am getting the following error when I run reportProcessor.RenderReport ( ) : I feel like this might be an issue with the way I 've configured my Azure app service . Here is my con...
Telerik Reporting produces pdf locally , but not on Azure
C_sharp : I am currently working with .Net 2.0 and have an interface whose generic type is used to define a method 's return type . Something likeMy problem is that some classes that implement this interface do not really need to return anything.In Java you can use java.lang.Void for this purpose , but after quite a bi...
java.lang.Void in C # ?
C_sharp : We have a legacy .NET Remoting-based app . Our client client libary currently supports only synchronous operations . I would like to add asynchronous operations with TPL-based async Task < > methods.As proof of concept , I have set up a basic remoting server/client solution based a modified version of these i...
Wrap .NET Remoting async method in TPL Task
C_sharp : I was looking at the IL code of a valid method with Reflector and I 've run into this : Instructions with the suffix .s are supposed to take an int8 operand , and sure enough this should be the case with Leave_S as well . However , 0x0103 is 259 , which exceeds the capacity of an int8 . The method somehow wor...
IL short-form instructions are n't short ?
C_sharp : I started a UWP app on a laptop running Visual Studio 2015 Update 3 . All was well and good , able to run and test it on both my laptop and my phone with no issues at all.I added the project to Source Control ( private Git server ) and pulled the repo on my home PC . The project opens in VS2015 Update 3 on my...
UWP app wo n't launch on second machine
C_sharp : I created a method to abstract try/catch functionality . I have about 30 methods that have this exact same try/catch scenario . So I put it in one method : Now , most of the methods call it like this : My issue is that I have just a couple of methods that call it without needing to return a value : However , ...
Use func method for an action also ?
C_sharp : So , I just hate using true/false as method arguments for `` enabled '' / '' disabled '' . To freely quote Jeff : `` I dislike it on a fundamental level '' .I repeatedly find myself defining my own enums on every new project in different namespaces all over the place , like these : Is there a generic enum I c...
Is there a ( well hidden ) generic enum anywhere in the BCL for Enabled/Disabled ?
C_sharp : Help me settle an argument here . Is this : treated exactly the same as this : Ie . does it make a difference if I state specifically that the string s is a const.And , if it is not treated in the same way , why not ? <code> SqlCommand cmd = new SqlCommand ( `` sql cmd '' , conn ) ; const string s = `` sql cm...
C # - Is this declared string treated as a const ?
C_sharp : In the code below , I am assigning a string to text box . The text box text is wrapped , so words will be shifted to the next line if they can not fit in same line.C # : XAML : Now , with the example above , it may happen that on the last line in the text box the word `` Eyes '' is the only word due to wrappi...
How to check if the last line in a text box has only one word ?
C_sharp : I 've noticed something odd about using the bitwise XOR operator on bytes in C # . Odd to my mind , at least.I also see this issue using short , but not int or long.I thought the last two lines were equivalent , but that does n't seem to be the case . What 's going on here ? <code> byte a = 0x11 ; byte b = 0x...
C # XOR operators : ^ vs ^= and implicit type conversion
C_sharp : I always saw people always talking about using framework like Ninject , Unity , Windsor to do the dependency resolver and injection . Take following code for example : My question is : why ca n't we simply write as : In that case seems we do n't need any framework , even for the unit test we can easily mock.S...
Why we need framework to do the Dependency Resolver ?
C_sharp : Given two implementations of Comparison methods : Why would n't the following conditional operator code block compile : Compiler error : `` Type of conditional expression can not be determined because there is no implicit conversion between 'method group ' and 'method group ' '' However , the equivalent code ...
Conditional operator and Comparison Delegate
C_sharp : I want to retrive the number sequence which is at the end of string . for e.g . gives me result 56 but I want the result as 1234 . How should I do this ? <code> string contentDbIndex = Regex.Match ( `` ab56cd1234 '' , @ '' \d+ '' ) .Value ;
How to get number at the end of string ?
C_sharp : I am building a little 2048 WinForms game just for fun.Note that this is not about a 2048 AI . I am just trying to make a 2048 game that can be played by humans.I first decided to use 0-17 to represent the tiles . 0 represents an empty tile . 1 represents a 2 tile . 2 represents a 4 tile . 3 represents a 8 ti...
How can I figure out which tiles move and merge in my implementation of 2048 ?
C_sharp : I am in the process of converting a Classic ASP/VBScript application to C # /ASP.Net . The VBScript part of the application is a series of individual scripts performed each month on a specific date with each individual task set up in Windows Scheduler . There are about 35 tasks which include database inserts ...
C # Scheduled Series Of Tasks
C_sharp : I 'm converting a VB.Net app into C # , and have noticed that in the VB.Net code , there is a private member variable , which is initialised using Me like this : When I convert this to C # code like this : I have the error Argument is value while parameter type is ref.If I put ref in front of the parameter th...
Why in C # this is not allowed in member initializer , but in VB.Net Me is allowed
C_sharp : I have two ServiceStack servers X and Y. Server X has functionality to register and authenticate users . It has RegistrationFeature , CredentialsAuthProvider , MemoryCacheClient and MongoDbAuthRepository features to handle the authentication.Recently , I introduced server Y and GUI forms that talk to server Y...
Passthrough Authentication in ServiceStack
C_sharp : I see several StackOverflow questions on this already but not of them seem to match my scenario . I promise I looked.I have some queries against my database that I 'm using linq to do and I ca n't figure out why the incorrect SQL is being generated . This is happening in several places in my code . I 'm hopin...
Why does Linq ignore my where clause ?
C_sharp : I am new to C # , so please bear with me as I have inherited a script that I 'm attempting to tweak.I want to get the output of SQL PRINT/RAISERROR statements to show up in a log file that has been declared in another part of the script.This is my method I 'm calling : This is the info handler method : Instea...
C # output SQL Server Messages to text file
C_sharp : At the risk of asking a question that has already been asked butis there a counterpart in Java for the Type type available in C # ? What I want to do is filling an array with elements which reflect several primitive types such as int , byte etc.In C # it would be the following code : <code> Type [ ] types = n...
type of types in Java
C_sharp : I am working on some code to use HttpWebRequest asynchronously . If any of you have ever done this before , then you know that error handling can be a bit of a pain because if an exception is thrown in one of the callback methods , it ca n't be passed back to the calling code via a try/catch block.What I want...
What 's the best way to handle asynchronous HttpWebRequest exceptions in C # ?
C_sharp : Given the following setup in TPL dataflow.i am wondering how I can mark this to complete because of the cycle . A directory is posted to the dirBroadcast broadcaster which posts to the dirfinder that might post back new dirs to the broadcaster , so i cant simply mark it as complete because it would block any ...
How to mark a TPL dataflow cycle to complete ?
C_sharp : Compiles but shouldn'tErrors but shouldn'tCompiler Error Text : -2147483648 can not be converted to a ulongQuestion : I would expect the opposite to occur . Can anyone explain why this is ? Also how I can print this flags attribute to a byte [ ] for inspection ? <code> [ Flags ] enum TransactionData : long //...
Unexpected behavior between [ Flags ] enum : long vs [ Flags ] enum : ulong
C_sharp : I 've been struggling with a problem when downloading very big files ( > 2GB ) on Silverlight . My application is an out-of-browser Download Manager running with elevated permissions.When the file reaches a certain ammount of data ( 2GB ) , it throws the following exception : The only clue I have is this site...
ArgumentOutOfRangeException when downloading file via Stream.Read
C_sharp : Is there any way to call write generic programs and algorithms in C # while avoiding the overhead of a dynamic solution ? Consider a simple example : Which you might call as : While seemingly efficient , this benign-looking example performs an indirect ( i.e . virtual ) call for every comparison.Obviously , t...
How to write generic code while avoiding indirect calls ?
C_sharp : Whenever I try to upload a large video via Direct Upload using the YouTube API . I get an OutOfMemory Exception . Is there anything I can do to get rid of this ? The YouTube API does not say anything about video size limit using direct upload.I gave up on the Direct Upload . Now I trying the resumable upload ...
YouTube Direct Upload - OutOfMemory Exception
C_sharp : I 'm using Facebook as a login provider for my web application ( ASP.NET MVC ) .My login works similar to another StackOverflow post How to securely authorize a user via Facebook 's Javascript SDK . I also share the user 's concerns.The flow for my login is as Follows:1 . The user presses the login button.2 ....
How do I use a Facebook signed_request in .NET ?
C_sharp : How does the is operator work with respect to the DLR ? To make my question a little more explicit , consider the following signature : By default , what conditions are necessary for Is < T > to return true ? Furthermore , does the DLR provide any mechanism to customize this behavior ? <code> public bool Is <...
How does the `` is '' operator work with dynamic objects ?
C_sharp : I have a simple Parent Child table in a database like soThe data that I have in them isParent TableChild TableThese tables are mapped to Parent and Child C # objects using the Linq-2-SQL designer in Visual Studio with no non standard options.I made a simple test program to query all child with their parentsTh...
Why does linq-2-sql create extra unnecessary objects ?
C_sharp : I read that sometimes that calling directly a Task can lead to a deadlock of the main thread.Here 's my async method : I tried a lot of ways to run this task in a sync function . Here 's some examples : I want to know which is better solution to run the async method synchronously in the syncFoo ( ) without ca...
Prevent deadlock by running a Task synchronously - Windows Service
C_sharp : I have a list of bool , and a list of strings . I want to use IEnumerable.Zip to combine the lists , so if the value at each index of the first list is true , the result contains the corresponding item from the second list . In other words : The simplest solution I could come up with is : ... but I suspect th...
Linq : Exclude results using Zip
C_sharp : When I use expression trees to replace a method , such as Math.Max , it looks like it successfully replaces it in the expression tree . But when I go to use it in Entity Framework , it throws an exception about not supporting Math.Max for Entity Framework . But I am explicitly replacing it.Does anyone know wh...
Expression Tree - Math.Max replacement
C_sharp : Suppose I have three objects : ' a ' , ' b ' and ' c'.Object ' a ' and ' c ' are long-lived , statically referenced service singletons.Object ' b ' is short-lived , i.e . no static references keep it alive.Now suppose object ' a ' creates an instance of object ' b ' in the scope of one of its methods , e.g.Fu...
does passing a method of one object to another object keep the first object alive ?
C_sharp : I 'm in the process of designing a system that will allow me to represent broad-scope tasks as workflows , which expose their workitems via an IEnumerable method . The intention here is to use C # 's 'yield ' mechanism to allow me to write psuedo-procedural code that the workflow execution system can execute ...
Is this good design of a workflow-esque system ?
C_sharp : I have some working code which produces a correct signature of a string if I load a certificate from a file or from the current user 's store . However , if I load the exact same certificate ( same .p12 and same thumbprint ) from the Machine certificate store , it behaves differently . When loaded from that s...
Cryptography : Why am I getting different RSA signatures depending on which certificate store the certificate was loaded from ?
C_sharp : With this code for a very basic logger : when I try it from a few threads simultaneously I quickly get the error : Why the lock is not preventing the threads to access the file at the same time ? It does n't matter if the threads call the same instance or different instances to the same file.Also I thought It...
Why the lock in this code is not working ?
C_sharp : Really curious for the below program ( yes run in release mode without debugger attached ) , the first loop assigns a new object to each element of the array , and takes about a second to run . So I was wondering which part was taking the most time -- object creation or assignment . So I created the second lo...
C # performance curiosity
C_sharp : I 'm designing an application that will allow me to draw some functions on a graphic . Each function will be drawn from a set of points that I will pass to this graphic class.There are different kinds of points , all inheriting from a MyPoint class . For some kind of points it will be just printing them on th...
Designing a class in such a way that it does n't become a `` God object ''
C_sharp : Doing an experiment of translating .NET IL to C++ in a human readable fashion.Here is the issue : C # allows you to resolve multiple interfaces with the same method name that only differ in return type . C++ does n't seem to support this however making resolving two interfaces impossible using the vTable ( or...
C++ multiple interfaces that only differ in return type ?
C_sharp : As you 're developing you often use things like oras a placeholder to remind you to finish something off - but these can be missed and mistakenly end up in the release.You could use something likeso it wo n't compile in Release build - but is there a more elegant way ? <code> throw new NotImplementedException...
Elegant way to stop release compilation with error
C_sharp : So I have a case where the layout has evolved to become more complicated . There 's the usual things like @ section styleIncludes { ... } , then other sections that define all kinds of the things that each page can optionally ( but almost always ) specify like the structure of the current pages breadcrumb . T...
Hint/Fluent for razor section names ?
C_sharp : When exposing a set of related functions in Powershell cmdlets , is it possible to share the property names and summary help to normalize these across cmdlets in an assembly ? I know that this can be done with derived classes , but this solution is awkward at best when there are multiple cmdlets with differen...
Is it possible to share properties and comments between Powershell cmdlets in c # ?
C_sharp : Given a list of dates in descending order , this code will find the largest date where the date is < = searchDate.How would I write a binary search function to replace this method ? I 'm struggling to implement it for an inexact comparison like this.This method is called frequently , and can contain several t...
Binary search list of dates for largest date where date < = n
C_sharp : I did a search for an HsbToRgb converter in the docs but did n't find anything containing `` hsb '' or `` hsl '' , so I 'm guessing it just does n't exist . Just to make sure , though , are there any classes that support this conversion ? UpdateI ended up going with this , which is slightly different than 0xA...
Does the .NET Framework 3.5 have an HsbToRgb converter or do I need to roll my own ?
C_sharp : If I run this test : I get the following result : When I use the regular For : The output is : The last result is a Triangular Distribution and it is the expected output.The purpose of my question is not to discuss the applicability of parallelism . The question is why the Parallel.For behaves that way ? <cod...
Parallel.For and For yield different results
C_sharp : I have the following function in c # : Since TModel is clear from a function parameter I want some way to not specify its type when calling a function . Ideally I want to call it like : Since this is probably impossible , I came up with the following : So I 'm now calling it like : Are there other possibiliti...
Syntax sugar for double-generic function
C_sharp : How to write correct Linq expression used in generic for condition `` where '' Repositor.csbut this with Linq expression will run <code> public static class ConStr { public static MySqlConnection Conn ( ) { return new MySqlConnection ( ConfigurationManager.ConnectionStrings [ `` DBCN '' ] .ConnectionString ) ...
Linq expression IEnumerable < TEntity > does not contain definition of where
C_sharp : It is second nature for me to whip up some elaborate SQL set processing code to solve various domain model questions . However , the trend is not to touch SQL anymore . Is there some pattern reference or conversion tool out there that helps convert the various SQL patterns to Linq syntax ? I would look-up way...
How to get linq to produce exactly the sql I want ?
C_sharp : I have a small 3D vector class in C # 3.0 based on struct that uses double as basic unit.An example : One vector 's y-value isI subtract a vector with an y-value ofThe value for y I would expect is Instead I getWhen I 'm doing the whole computation in one single thread , I get ( 1 ) . Also the debugger and VS...
Can floating-point precision be thread-dependent ?
C_sharp : For some reason my stored procedure is executed without any error from the code-behind in C # but it is not deleting anything at all that the stored procedure has written . I have all the correct parameters and everything . I ran the query from SQL Server with all the same parameters from the C # code and it ...
Stored procedure not running correctly with dynamic sql text
C_sharp : When loading a rtf file into a Windows Forms RichTextBox it loses the background colour of table cells . If we use a WPF RichTextBox and load the same file everything is formatted as it should.Am I missing something when I load the file into the Windows Forms RichTextBox ? Windows Forms RichTextBox code snipp...
Windows.Forms.RichTextBox Loses table background colours
C_sharp : This was mentioned in my other question and I thought it might be useful to add it to the record . In the following program , which , if any , of the locally defined delegates are cached between calls to the Work method instead of being created from scratch each time ? <code> namespace Example { class Dummy {...
Which ( if any ) locally defined delegates are cached between method calls ?
C_sharp : For each entity that has a one to many relation with other entity when i trying to add a new item it seems like i have to define these list of items that relates to this entity.For example , lets say that i have a ProductType entity that has a list of Products as following : when i try to add a new ProductTyp...
How Can I define Nullable EntitySet < > ?
C_sharp : I 'm looking for a way to navigate between screens in my app . Basically what I 've seen so far consists of passing a string URI to the NavigationService , complete with query string parameters. , e.g.I 'm not really keen on this though ultimately because it requires magic strings , and they can lead to probl...
Is there a typesafe way of navigating between screens in Windows Phone ?
C_sharp : The azure role setting , is very useful since it lets you change values on-the-fly while IIS is running . But the problem is , if you have plenty users , and if it reads every time the config value from file , it is not best practice to use it without putting it in a static variable . The next problem , if yo...
Does RoleEnvironment.GetConfigurationSettingValue read every time from cfg file ?
C_sharp : Basic C # question here.What is the difference between creating an instance of a class property / field either as you declare it or in the constructor of the object in question . For example : vs <code> public class MyClass { public MyObject = new MyObject ( ) ; } public class MyClass { public MyObject ; publ...
C # - What 's the difference between these two ways of instancing a class property ?
C_sharp : Silverlight Unit Test Framework has an [ Asynchronous ] attribute ( AsynchronousAttribute ) that causes the tests to only end when EnqueueTestComplete ( ) gets called . This allows for a simple way to write tests that need to wait for an event to occur before they end . Now I am trying to pick a favorite gene...
Asynchronous tests in VSUTF , NUnit , xUnit.NET , MbUnit vs. SUTF ?
C_sharp : I am querying an xml file and returning 3 attributes per selection ( each entry that meets my criteria will return 3 attributes details ) . I need to store these values , and then later look up the first attribute , and return the 2 other stored attributes related to it . The above code returns 3 attributes p...
How to store and lookup data , based on multiple xml attributes ?
C_sharp : The question seems simple . Although the documentation says it does : the following code gives an error : saying that there is no conversion from KeyCollection < T > to IReadOnlyCollection < T > .Moreover polish documentation ( french too for that matter ) says it does not : Which is it ? And in case it 's th...
Does ` Dictionary < TKey , TValue > .KeyCollection ` implement ` IReadOnlyCollection ` or not ?
C_sharp : when choosing a character I currently have a base classAnd my characters derive from this classLastly I use this code to select the WarriorSo this way works pretty fine . But when it comes to cooldowns etc . I want to stay with a clean code so I thought about creating a Ability class.My abstract parent classT...
creating ability objects in Unity
C_sharp : I have a design problem that I ca n't figure out . Here 's what I 've got : In general , I have two general types of objects Strikes and Options . These have been abstracted into two interfaces IStrike and IOption.Let 's say that IOption has the following fields , in reality there are about 10 times as many ,...
Can I combine composition and inheritance with interfaces in C #
C_sharp : Excel 2016 seems to trigger a programmatically added undo level upon saving , which does not happen in earlier versions of Excel ( 2013 , 2010 , and 2007 ) . To reproduce this apparent bug , open a new workbook and save it as a macro-enabled workbook ( .xlsm file ) . Paste the following code into the ThisWork...
Excel 2016 triggers undo upon save bug ?
C_sharp : I 've borrowed the code below from another question ( slightly modified ) , to use in my code : The original author of this code correctly adheres to the warnings given in MSDN 's implicit & explicit documentation , but here 's my question : Is explicit always necessary in potentially exceptional code ? So , ...
Why/when is it important to specify an operator as explicit ?
C_sharp : I have an Web API 2 end point where by I want to asynchronously carry out an operation while I retrieve and verify a user . If this user does not exist I want to return a 404 Not Found like so : Could this cause me potential issues if the user was to equal to null and the method returned without awaiting the ...
Bad practice to return from method before async operation completes ?
C_sharp : I 'm looking for a way to program a custom authorization filter in ASP.NET 5 as the current implementation relies in Policies/Requirements wich in turn rely solely in the use of Claims , thus on the umpteenth and ever-changing Identity System of wich I 'm really tired of ( I 've tried all it 's flavours ) .I ...
DI into a Requirement/Policy in ASP.NET MVC 6
C_sharp : I was recently attempting to answer a question that a user posted about why the decimal struct does not declare its Min/Max values as const like every other numeric primitive ; rather , the Microsoft documentation states that it is static readonly.In researching that , I dug through the Microsoft source code ...
'Decimal ' source code from Microsoft - will it build ?
C_sharp : I have a requirement that calls for matching a Sample Set of color values against a Known Set of values to find either an exact match , or matches that are within an acceptable distance . I 'm not entirely sure what algorithm would be best suited for this and I 'm looking for suggestions . I thought about usi...
Suggest an algorithm for color pattern matching against a large known set
C_sharp : In Xamarin google maps for Android using C # you can create polygons like so based on this tutorial : However I have downloaded a CSV file from my Fusion Table Layer from google maps as I think this might be the easiest option to work with polygon/polyline data . The output looks like this : I uploaded a KML ...
Extracting data from CSV file ( fusion table and kml workaround )
C_sharp : During development I had a TempTextBlock for testing and I 've removed it now . It builds successfully , but when I try to create a package for store , it gives this error : error CS1061 : 'MainPage ' does not contain a definition for 'TempTextBlock ' and no extension method 'TempTextBlock ' accepting a first...
Page does n't contain a definition for X
C_sharp : Here 's the simplified case . I have a class that stores a delegate that it will call on completion : I have another utility class that I want to subscribe to various delegates . On construction I want itself to register to the delegate , but other than that it does n't care about the type . The thing is , I ...
Constructor that takes any delegate as a parameter
C_sharp : My expectation is that AutoMapper ( 3.3.0 ) does not automatically resolve string - > DateTime conversions , even when the string is in a well-understood format . The lack of inclusion of a default string - > DateTime converter is noted ( albeit four years ago ) in a comment by the library author , Jimmy Boga...
AutoMapper inconsistently automatically resolving string - > DateTime
C_sharp : OK , Custom Policy Based Authorization in ASP.NET Core . I kinda of understood the idea of this new identity framework , but still not 100 % clear what you can achieve with this . Assuming we have an Action in HomeController called List . This action will query and display a list of products from the database...
ASP.NET Core Custom Policy Based Authorization - unclear
C_sharp : I 'm launching an external application from a ContextMenu , and I must block the the source application while the target application is running . To achieve this I 'm using Process.WaitForExit ( ) to avoid the source application responding to events.The problem is the context menu is still ahead the target ap...
WPF ContextMenu still visible after launching an external process
C_sharp : Is there a way I can determine in .NET , for any arbitrary SQL Server result set , if a given column in the result can contain nulls ? For example , if I have the statementsand and I get a datareader like this : can I have a function like this ? I want it to return true for the first statement , and false for...
SqlDataReader find out if a data field is nullable
C_sharp : I have a List < T > of available times within a 24 hour day , and two TimeSpans , minTime and maxTime.I need to find a time of day within the List < T > that lands between the minTime and maxTime , however due to this being used in multiple timezones , the minTime and maxTime can be on separate days and span ...
What am I missing in this algorithm to find a TimeOfDay between two TimeSpans that may span separate days ?
C_sharp : I was using Dapper and having it return a dynamic IEnumerable , like this : Here , rows is of type IEnumerable < dynamic > . The IntelliSense says FirstOrDefault ( ) is awaitable , and has the usage await FirstOrDefault ( ) . Not all LINQ queries are shown as awaitable , but it seems like especially those tha...
Why is First ( ) or ElementAt ( ) on a dynamic IEnumerable awaitable ?
C_sharp : I have a Control lblDate in User Control MainScreen . I would like to modify it in a method in class Date , which is in another project AoWLibrary . I ca n't reference it because AoWLibrary is a dependent of the first project.I tried to make lblDate static but the compiler kept throwing errors at me , and I h...
Modify Windows Forms Control from another Project
C_sharp : When writing a method chain for LINQ , I can do the Where statements one of two ways : Or Are there any benefits of one over the other ? Do n't worry too much about the datatypes in this example , but if there are issues with datatypes , then that would be good to know too.The obvious one is that the object i...
Linq Where Clauses - Better to stack or combine ?
C_sharp : I 'm currently working on an emulation server for a flash-client based game , which has a `` pets system '' , and I was wondering if there was a simpler way of going about checking the level of specified pets.Current code : Yes , I 'm aware I 've misspelt Experience , I had made the mistake in a previous func...
Simpler / more efficient method of nested if ... else flow ?
C_sharp : I am writing a Cmdlet and need to pass object structures into an API client that may contain PSObjects . Currently , these serialise as a JSON string containing CLIXML . Instead , I need it to be treated like an object ( including the NoteProperties in PSObject.Properties as properties , and recursively seria...
How can I serialise PSObjects in C # with JSON.NET ?
C_sharp : I have a method with the following signatureFrom a point in my code I need to move up the stacktrace to find the closest method with the SpecificationAttribute ( performance is not an issue here ) . I find this method but I can not find any custom attributes on it.I do n't think I 've ever seen this happen . ...
Why can I not find a custom attribute on this MethodInfo
C_sharp : PreambleI 'm trying to disassemble and reverse-engineer a program whose author is long gone . The program provides some unique features that I have yet to find elsewhere and ... I 'm curious and intrigued by reverse-engineering the program . If you 're just gon na try and help me find another program ... do n...
Ca n't decrypt these strings
C_sharp : Does anyone know why the last one does n't work ? <code> object nullObj = null ; short works1 = ( short ) ( nullObj ? ? ( short ) 0 ) ; short works2 = ( short ) ( nullObj ? ? default ( short ) ) ; short works3 = 0 ; short wontWork = ( short ) ( nullObj ? ? 0 ) ; //Throws : Specified cast is not valid
Null coalescing operator giving Specified cast is not valid int to short
C_sharp : I am trying to get the heart rate from a Microsoft Band . It should be updating whenever the value changes . I am then trying to display that value in a TextBlock . I first create an instance of IBandClient , and set its HeartRate.ReadingChanged method like this : Then I try to update the value like this : He...
Get Heart Rate From Microsoft Band
C_sharp : Eric Lippert has explained in his blog post at http : //blogs.msdn.com/b/ericlippert/archive/2009/12/10/constraints-are-not-part-of-the-signature.aspx why constraints are not considered for type inference , which makes sense given that methods can not be overloaded by simply changing type constraints . Howeve...
Is there a workaround to C # not being able to infer generic type arguments using type constraints ?
C_sharp : Is there any difference between the following two statement ? They both work . <code> if ( ( ( Func < bool > ) ( ( ) = > true ) ) ( ) ) { ... . } ; if ( new Func < bool > ( ( ) = > true ) ( ) ) { ... . } ;
Cast to Func vs new Func ?
C_sharp : I declared the function Process32FirstW and the structure PROCESSENTRY32W like this : When calling Process32FirstW ( with a 64-bit process ) , I always get a TypeLoadException saying The type ProcessEntry could n't be loaded , because the object field at offset 44 is aligned wrong or is overlapped by another ...
` PROCESSENTRY32W ` in C # ?
C_sharp : I get file size =0the finilizer should have executed because I derive from CriticalFinalizerObjectI do n't want to use Trace.Close ( ) not in the Finalizer.editafter @ eric Lippert reply : Ive re-edited the code trying to match it to : constrained execution region ( but still no success ) <code> class Program...
Why my Close function is n't called ?
C_sharp : I have been trying to use Deedle F # Library to write an F # batch program . It has worked perfectly . However , I am not sure about the best design for the following 2 tasks : Combine the F # module into a existing ASP.net MVC/Web Api systemCreate a WPF interface to serve as a control panel and visual depend...
Designing an F # module to be called by C # ( Console/MVC/WPF )
C_sharp : I want to Serialize and DeSerialize an object which contains a Lazy Collection of some custom objects . Normally everything works perfectly fine but , if namespaces of classes used for serialization are changed , then this issue occurs . I have written a SerializationBinder to point to right classes while des...
Not able to deserialize Lazy object
C_sharp : I encountered some interesting behavior in the interaction between Nullable and implicit conversions . I found that providing an implicit conversion for a reference type from a value type it permits the Nullable type to be passed to a function requiring the reference type when I instead expect a compilation e...
What is the justification for this Nullable < T > behavior with implicit conversion operators
C_sharp : In .NET Core and .NET Framework 4.x the following code works as expected : However , in netstandard , the Name property in Group is gone . I 'm wondering if there is a new way of achieving the same thing , or if this is a bug.Edit : I first thought this was a netstandard 2.0 issue , but it looks like the prop...
netstandard - Regular Expression , Group Name inaccessible
C_sharp : Take the following code : using those typesCompiled with C # 5 compiler against .NET 4.5.1 ( the behaviour is probably the same using older compiler/framework version ) this generates the following error : Now , I have a pretty good idea what is happening under the covers ( I blogged about it here ) but I ca ...
C # dynamic fails invoking method from a base interface
C_sharp : I 'm writing a Tetris-clone and I 'm prototyping in C # . The final code is supposed to run on an embedded system ( using an 8-Bit CPU and very little RAM ) , so I 'm trying to use a naïve algorithm to do line clear.Right now , my playfield is a 2D Array : ( where TetrominoType is an enum to indicate either N...
Naive Gravity for Tetris game using 2D Array for the playfield
C_sharp : In C++ the compiler knows about primitive data types such as int , but in C # these are basically structures ( e.g . System.Int32 ) . But can I assume that C # knows about these types . I think that it does , because an int literal in C # is basically an instance of System.Int32 . For example this will work :...
Are C # primitive data types part of the language ?
C_sharp : I have a Windows application that is connecting to a WCF Data Service hosted on the same machine.The first thing that occurs when the application starts is a query that returns 0 to 3 results . Here 's the code : The very next thing I do is check if ( environments.Count ( ) == 0 ) which takes about 10 seconds...
Why is WCF Data Service performing better while Fiddler is running ?
C_sharp : I am testing my asp.net core 2.2 web api with Postman . I write the JSON manually like this ( httppatch ) : Now I am thinking how can I build the patch body on the client side.My question is how can I get the equivalent of this code in json to make it look like the one I write manually ? I guess it 's all abo...
Mongodb Bson type to Json
C_sharp : I have an interesting situation . When I run a query on remote SQL server in Microsoft SQL Server Management Studio it runs fast ( 12 sec ) , but when I run the same query in Entity Framework using DbContext.Database.SqlQuery < EntityType > ( script ) it takes 48 seconds.I tried setting set arithabort on . Th...
Entity Framework data reading performance
C_sharp : Given this XML ... And this C # code : I know the Xdoc is not empty and contains the right XML.I also implemented some ScottGu code ( http : //weblogs.asp.net/scottgu/archive/2007/08/07/using-linq-to-xml-and-how-to-build-a-custom-rss-feed-reader-with-it.aspx ) as a sanity check and it works exactly as expecte...
Why is n't this LINQ to XML Query Working ( Amazon S3 )
C_sharp : I 've a project where I am extensively using the generic C # dictionary . I require composite keys , so I 've been using tuples as keys . At some point I was wondering whether it would be beneficial to use a custom class which caches the hash code : I used new instead of override because I thought it would no...
Why does the C # dictionary not call the hidden GetHashCode method