Menu
  • HOME
  • TAGS

Async task raises NotImplementedException

c#,windows-phone-8.1,async-await,.net-4.5

Why your code for ConvertToBase64 isn't being awaited? This is completely wrong, as the async void construction. Try to change your code to something like this: newOffer.photoBase64 = await SetPhotoString(Photo);//this line throws an excp. public async Task<string> SetPhotoString(BitmapImage bi) { return await bi.ConvertToBase64(); } Also, what line of the ConvertToBase64...

Hashtable insert failed. Load factor too high : .Net 4.5

exception,.net-4.5

The hot fix for 4.5 is available here : kb2803754 And we need to contact the Microsoft support to get the hot fix installation file. MSDN thread for KB2803754 in .NET 4.5.1 framwork...

Batch File works when run, but fails when run from app

.net,batch-file,command-line,.net-4.5

There is also a windows CMD command called convert. Make sure that ImageMagick is infact accessable to your application through environment variable PATH or maybe directly specifying your ImageMagick/convert executable path in your batchfile. so in short i suspect your application is calling CMD convert (converting filesystem) instead of ImageMagick/convert...

WEB API call stops working after introducing the “await” keyword

c#,asp.net-mvc,asp.net-web-api,.net-4.5,c#-5.0

"await" essentially means that you are making the runtime to wait until the method is executed. The first code snippet returns a task object while the second returns the actual services from db. Since you are saying that with first code block it displays the services you must be awaiting...

UriBuilder not combining two uris correctly

c#,.net,.net-4.5

What am I doing wrong? You're combining the constructor and initialization syntax, which is overwriting the .Path property completely, not appending to it. Essentially... var uriBuilder = new UriBuilder("D:\\Test"); // uriBuilder.Path is now "D:\\Test" // ToString() will give "file:///D:/Test" uriBuilder.Path = "locations"; // ToString() will give "file://locations", because Path...

Get Properties out of LogicalBinaryExpression ; How?

c#,vb.net,lambda,.net-4.5

To extract information from an expression it is recommend to use a custom visitor. The following visitor will return "Id = 1" when you execute it with your expression : Public Class WhereVisitor Inherits ExpressionVisitor Public Shared Function Stringify(expression As Expression) As String Dim visitor As New WhereVisitor() visitor.Visit(expression) Return...

Implement a WCF-Mock and the endpoint before implementing the real service

c#,wcf,.net-4.5

Yes. You will need to create a class that acts as an intermediary for the WCF service client calls and then either loads an actual client or your mock service depending on some value (probably a config value). This way, the dependencies in your code are handled such that all...

ListBox inside a ListBoxItem template

wpf,wpf-controls,.net-4.5

You could replace the inner ListBox with an ItemsControl. Based on your question it sounds like you just need to display a collection, and prevent the user from interacting with it. A simple ItemsControl is well suited for that. The ItemsControl does not support selection, so the click will get...

Use Task or Thread when Coding a Remote Desktop Capture App [closed]

c#,.net,multithreading,.net-4.5

You probably don't need to use the Thread class, it is quite low level and difficult to combine separate asynchronous operations together. Task APIs are much easier to use and combine multiple asynchronous operations together, they also support cancellation and have language support through the async and await keywords which...

Passing a task as parameter

c#,.net,task-parallel-library,async-await,.net-4.5

Of course, simply invoke the func, get back a task, and await it: async Task Method(Func<Task<Entity>> func) { // some code var a = await func(); // some code } Also, when you're sending that lambda expression, since all it's doing is calling an async method which in itself returns...

Build platform target AnyCPU EXE still shows 32bit header in 64bit machine

c#,visual-studio-2012,.net-4.5,32bit-64bit,anycpu

You are misinterpreting CorFlags I think. Here is a CorFlags truth table: CPU Architecture PE 32BITREQ 32BITPREF ------------------------ ----- -------- --------- x86 (32-bit) PE32 1 0 x64 (64-bit) PE32+ 0 0 Any CPU PE32 0 0 Any CPU 32-Bit Preferred PE32 0 1 As you can see, it will only...

Deserializing Json data to c# for use in GridView - Error Data source is an invalid type

c#,json,gridview,serialization,.net-4.5

You're binding the container object, not the list itself. Change it to: GridView1.DataSource = personDetail.PersonDetails; And it should work....

Timeout.InfiniteTimespan in .Net 4.0?

c#,.net,timer,.net-4.0,.net-4.5

TimeOut.InfiniteTimeSpan in TimeOut class is defined as: public static readonly TimeSpan InfiniteTimeSpan = new TimeSpan(0, 0, 0, 0, Timeout.Infinite); Where Timeout.Infinite is set to -1,so it is passing -1 value for milliseconds part. You can do: TimeSpan InfiniteTimeSpan = new TimeSpan(0, 0, 0, 0, -1); ...

Warning as Error: Possible unintended reference comparison when upgrading from .Net 3.5 to .Net 4.5

c#,reference,.net-3.5,comparison,.net-4.5

Your previous code was broken, basically. You say it worked, but I can't see that the condition would ever be false. I suspect the compiler is just smarter now than it was before. The condition was: typedSender.InputHitTest(e.GetPosition(typedSender)) != typedSender.GetType() Now InputHitTest returns a value of type IInputElement. So the condition...

Adding footer/EXIF (binary data) to JPG image in C#

c#,.net,jpeg,.net-4.5

here is my tested solution for EXIF/MakerNote creation As far as I have read 37500 is the makernote hexdecimal tag inside EXIF. http://nicholasarmstrong.com/2010/02/exif-quick-reference/ public void CreateMakerNoteJpgImage(byte[] makerNoteArray, string path) { BitmapPalette myPalette = BitmapPalettes.WebPalette; // Creates a new empty image with the pre-defined palette BitmapSource image = BitmapSource.Create( Width, Height,...

How to edit the Typescript 1.4 “specified task executable location”?

asp.net-mvc-4,visual-studio-2013,typescript,.net-4.5

I had the same problem. Only way I found it just create a new folder '1.4' at C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.4 and copy to 'C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.4**1.4**' all files from parent directory. Stupid solution, but it works for me....

Create expression for a simple math formula

c#,.net,expression,.net-4.5,expression-trees

Problem with your code is that you have two instances of x parameter. One of them is private static field that is used across expression generation, and second one is that you create and use in Lambda creation. If you have ParameterExpression, then you should use the same instance in...

.Net BinaryWriter automatically flushes stream when checking stream Position

c#,.net,stream,.net-4.5,flush

Looks like the BinaryWriter class forces excessive Flushing and there's no way to override it. I'll just keep a reference to the original stream and check position on it directly. I found the (alleged) source code here: http://reflector.webtropy.com/default.aspx/[email protected]/[email protected]/DEVDIV_TFS/Dev10/Releases/RTMRel/ndp/clr/src/BCL/System/IO/[email protected]/1305376/[email protected] /* * Returns the stream associate with the writer. It flushes all...

How can I change my current selected item by either the key or value of my datasource?

c#,winforms,.net-4.5

You can do it with a little extension method I found here Just put this into an extension class. public static KeyValuePair<TKey, TValue> GetEntry<TKey, TValue> (this IDictionary<TKey, TValue> dictionary, TKey key) { return new KeyValuePair<TKey, TValue>(key, dictionary[key]); } And then you can just set your item like this comboBox1.SelectedItem =...

BeginFlush seems to work synchronously

c#,.net,multithreading,.net-4.5,httpresponse

The effect you are seeing may be related to SycnhronizationContext used by ASP.NET. Depending on .NET version and whether your code executes under ASP.NET page or something else, the behavior may change. Generally, it is normal for the SynchronizationContext to execute the callback on the same thread which started the...

Entity framework object not updating after being passed around

c#,entity-framework,dependency-injection,ninject,.net-4.5

Probably you are not sharing the same DBContext Between GetTransactionDetails and AddAuthoritzation. Due to this reason Entity Framework is not able to track the changes. Set the scope life of DBContext for web request, you can do it with Ninject with .InRequestScope() https://github.com/ninject/ninject/wiki/Object-Scopes , with this option the same DBContext...

Why the async await not working as expected

c#,task-parallel-library,async-await,.net-4.5,c#-5.0

No, because in fact you're sleeping for 7 seconds before you print Waiting started. Here's what happens: Main calls ProcessNumber ProcessNumber sleeps for 1 second ProcessNumber calls IncrementNumber IncrementNumber sleeps for 6 seconds IncrementNumber performs a computation, then returns a completed task ProcessNumber awaits that completed task, and continues ProcessNumber...

Unexpected token while parsing Facebook RSS

c#,facebook,winforms,rss,.net-4.5

For anyone with same issue, I couldn't solve it using SyndicationFeed.Load() but with XDocument.Parse(xmlString) instead of.

Wait for IProgress Report Method to Return

c#,multithreading,asynchronous,task,.net-4.5

The Progress<T> class uses a SynchronizationContext to invoke the reporting handler in an asynchronous manner. This is done to update the UI on the UI thread in WPF or WinForms. If that's not what you want (and it obviously isn't needed in your Console application), don't use the IProgress<T> interface...

how to handle multiple developer environment in web.config

asp.net,.net-4.5,asp.net-web-api2

The way we handle this is to use a separate config for connection strings, which is excluded from the repository. In Web.Config, the connection strings section looks like this: <connectionStrings configSource="Config\ConnectionStrings.config" /> The config folder has two files: ConnectionStrings.Config ConnectionStrings.Config.Template The template file consists of this: <connectionStrings> <add name="ConnectionString" connectionString="[...]"...

Check windows user existence without linking additional dlls and throwing exeptions in c#

c#,windows-8,.net-4.5

You should check agains the active directory, to be sure wether a user really exists. When you only check the local computer, only users which has logged in to the computer will be returned. If you don't want to use an additional assembly (which will be recommended) you can use...

HttpClient.PutAsync finish immediately with no response

c#,async-await,.net-4.5,dotnet-httpclient

You're executing this from a console application, which will terminate after your call to send. You'll have to use Wait or Result on it in order for Main not to terminate: private static void Main(string[] args) { var sendResult = send(options.FileName, options.Url).Result; Console.WriteLine(sendResult); } Note - this should be only...

Switch-Case on Class.PropertyName (not value)

c#,.net-4.5

You can use Expression<Func<T>> to do what you want. Define this method: private string ToPropertyName<T>(Expression<Func<T>> @this) { var @return = string.Empty; if (@this != null) { var memberExpression = @this.Body as MemberExpression; if (memberExpression != null) { @return = memberExpression.Member.Name; } } return @return; } Then you can write this:...

Shortest way to deserialize XmlDocument

c#,xml,.net-4.5,.net-4.6

You could forgo the XmlReader and use a TextReader instead and use the TextReader XmlSerializer.Deserialize Method overload. Working example: void Main() { String aciResponseData = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><tag><bar>test</bar></tag>"; using(TextReader sr = new StringReader(aciResponseData)) { var serializer = new System.Xml.Serialization.XmlSerializer(typeof(MyClass)); MyClass response = (MyClass)serializer.Deserialize(sr); Console.WriteLine(response.bar); } }...

Constant value cannot be converted to int

c#,.net-4.5

Compile-time constants are checked differently to other code, basically. A cast of a compile-time constant into a type whose range doesn't include that value will always fail unless you explicitly have an unchecked expression. The cast is evaluated at compile time. However, the cast of an expression which is classified...

Need to call method as soon as server starts responding to my HttpWebRequest

c#,winforms,httpwebrequest,.net-4.5,httpwebresponse

The closest I can think of is using HttpClient and passing a HttpCompletionOption.ResponseHeadersRead, so you can start receiving the request once the headers are sent and later start processing the rest of the response: public async Task ProcessRequestAsync() { var httpClient = new HttpClient(); var response = await httpClient.GetAsync( url,...

WPF Controls - Should code behind be avoided at all costs?

c#,wpf,.net-4.5

No, it should not be avoided at all costs. Remember, Data is Data, UI is UI. For example, if you have code which does only UI stuff, then there is nothing wrong with having code behind. Anything that works with actual data, including working with the ViewModel should generally be...

Why doesn't my Task.ContinueWith execute in .NET 4.5?

c#,.net,asynchronous,.net-4.5

Here we have problem with design of ContinueWith and TaskScheduler's properties Current and Default in these two versions of .Net In .Net 4.0 the TaskScheduler's Current and Default both has same value i.e. ThreadPoolTaskScheduler, which is ThreadPool's context scheduler and it's not the one that updates the UI i.e. SynchronizationContextTaskScheduler...

C# xml deserialization ignoring List<> properties unexpectedly

c#,xml,serialization,.net-4.5

This is never going to work like you've assumed. During deserialization, XmlSerializer invokes the getter to retrieve a presumably empty List<T> instance, and then calls its Add(T item) method to fill it with deserialized objects. The documentation in MSDN, in particular, says: The XmlSerializer gives special treatment to classes that...

Getting a System.AccessViolationException only during debug

c#,.net,visual-studio-2013,.net-4.5

It looks like this VS bug: Weird Access Violation Exception Reported here: https://connect.microsoft.com/VisualStudio/feedback/details/911564/access-violation-exception-in-vs-hosting-process-when-debugging-application And assumingly fixed in this .NET release: http://www.microsoft.com/en-us/download/details.aspx?id=42642...

80040154 Class Not Registered (Debenu PDF Library)

vb.net,dll,runtime-error,.net-4.5,windows64

It might be that you registered the 64-bit edition of the ActiveX but your project was set to x86 (32-bit). You can try the following test: Unregister both 32-bit and 64-bit versions of the Lite ActiveX regsvr32 [path here]\DebenuPDFLibrary64Lite.dll /u regsvr32 [path here]\DebenuPDFLibraryLite.dll /u Register only the 64-bit version of...

Is Parallel.ForEach obsolete. old, out of fashion?

multithreading,design-patterns,parallel-processing,async-await,.net-4.5

I don't think Parallel.ForEach is obsolete. Ever since introducing the Task Parallel Library (TPL) with .NET 4, Microsoft has distinguished between "Data Parallelism" (e.g. Parallel.ForEach) and "Task Parallelism" (Task). From MSDN: "Data parallelism refers to scenarios in which the same operation is performed concurrently (that is, in parallel) on elements...

WPF calling asynchronous code with out locking on Task..WhenAny()

c#,.net,wpf,async-await,.net-4.5

You can achieve that with AsyncBridge. E.g. using (var asyncBridge = AsyncHelper.Wait) { asyncBridge.Run(DoWorkAsync()); } It works by installing a custom SynchronizationContext and using that to wait for the task whilst freeing the UI thread. Because it is using synchronization context rather than using the dispatcher directly it is essentially...

Rotate gauge needle in C#

c#,wpf,graphics,.net-4.5

Thanks for the very useful code example. It made understanding your problem much easier. So, what's the answer? Well, I have a couple of suggestions. First, you're really going about the whole bitmap stuff the wrong way, by using the System.Drawing namespace, which is primarily designed to support Winforms. Hence...

Will a long running .net process be termintated if the user session is terminated?

c#,session,asp-classic,.net-4.5

I'd say: Start the text file processing in a separate thread, that way you won't have to consider things like the regular http request timeout (default 20 minutes) etc. Regarding feedback to the users, do you expect them to stick around for 20 hours looking at the browser? If not,...

How to place cursor in the first position of a Datepicker control in C#?

c#,wpf,datepicker,.net-4.5

You should find TextBox element and subscribe to event PreviewMouseUp. 1) Add DatePicker with Loaded event: <DatePicker Name="myDatePicker" Loaded="MyDatePicker_OnLoaded" /> 2) Find TextBox element (in the DatePicker type of the text box element is DatePickerTextBox) and subscribe to PreviewMouseUp: private void MyDatePicker_OnLoaded(object sender, RoutedEventArgs e) { var tb = (DatePickerTextBox)myDatePicker.Template.FindName("PART_TextBox",...

changing image background in button does not work

c#,windows-phone-8.1,.net-4.5

Set build action of images to content, use proper tags for your Uri, remove Relative URI. var uriString = bk1 ? @"ms-appx:/Assets/image1.png" : @"ms-appx:/Assets/image2.png"; k1.Background = new ImageBrush { ImageSource = new BitmapImage(new Uri(uriString)) }; ...

Why does String.Format fail to escape characters when the string is in a resource?

c#,string,.net-4.5,string-formatting

String.Format does not escape anything. It's the compiler, that processes \n, \t and other escape sequences in string literals into something else (that is, if you look at the binary, produced by compiler and search for your string, you will not find literal \ character followed by n there, but...

HTTPClient getting two 401s before success (sending wrong token)

c#,.net,http,authorization,.net-4.5

What you are experiencing is normal, this is how the NTLM authentication scheme works. 1: C --> S GET ... 2: C <-- S 401 Unauthorized WWW-Authenticate: NTLM 3: C --> S GET ... Authorization: NTLM <base64-encoded type-1-message> 4: C <-- S 401 Unauthorized WWW-Authenticate: NTLM <base64-encoded type-2-message> 5: C...

How do I make non-essential computations run in the background?

c#,concurrency,task-parallel-library,.net-4.5

How do I accomplish this? You can do this by changing BoundingBox to a Task<BoundingBox> which will be completed in the future. public static ptsTin Load(String file) { // Essential Work ptsTin newTin = new ptsTin(); newTin.LoadPoints(file); newTin.LoadTriangles(file); // At this point I could return, but I want other...

wrap anonymous function with another call

c#,visual-studio-2013,.net-4.5

func.Target is null because this delegate doesn't have any instance which it is invoked on. You can try following code: Calls.Add(c => ExtraCall((int)func(c))); ...

StackExchange.Redis HGET/HGETASYNC returns null when hash key is GUID

c#,.net,redis,.net-4.5,stackexchange.redis

From your comments, the guid here seems to be the hash field sub-key. Fundamentally, it works fine; see: static void Main() { int i = new Random().Next(); Console.WriteLine("> {0}", i); Guid guid = Guid.NewGuid(); using (var muxer = ConnectionMultiplexer.Connect("127.0.0.1:6379")) { var db = muxer.GetDatabase(); db.KeyDelete("foo"); db.HashSet("foo", guid.ToByteArray(), i); } using...

How do I change the value of a query string parameter?

c#,.net-4.5

If the rest of the URL is fixed, you could locate the id manually, and use string.Format and string.Join to insert the IDs into it: var urlString = string.Format( "http://www.GoodStuff.xxx/services/stu/query?where=1%3D1&text=&objectIds={0}&time=" , string.Join("%", ids) ); This will insert a %-separated list of ids from your code into the URL template....

Wait for download to complete

c#,download,.net-4.5

You can have startDownload wait for the asynchronous file download through Application.DoEvents() like this: private bool downloadComplete = false; private void startDownload(Uri toDownload, string saveLocation) { string outputFile = Path.Combine(saveLocation, Path.GetFileName(toDownload.AbsolutePath)); WebClient client = new WebClient(); client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged); client.DownloadFileCompleted += new AsyncCompletedEventHandler(client_DownloadFileCompleted);...

Is LogicalOperationStack incompatible with async in .Net 4.5

c#,.net,async-await,.net-4.5

Yes, LogicalOperationStack should work with async-await and it is a bug that it doesn't. I've contacted the relevant developer at Microsoft and his response was this: "I wasn't aware of this, but it does seem broken. The copy-on-write logic is supposed to behave exactly as if we'd really created a...

BeginExecuteReader, EndExecuteReader and multiple results

c#,.net,asynchronous,.net-4.5,sqldatareader

I have tested this and I think the problem is here: dt1.Load(dr); if (dr.NextResult())//I can't access second table in results { dt2.Load(dr); } From what I can see the the call to Load automatically advances the SqlDataReader to the next record set, so your call to dr.NextResult() will return false....

How to write an extension method to return the type being used?

c#,.net,.net-4.5,extension-methods

You could just make the receiver of EnableLazyLoading a generic type constrained to be an IBaseService. It's wordy, but ought to do the trick. public static TService EnableLazyLoading<TService, TEntity, TKey>(this TService service) where TService : IBaseService<TEntity, TKey> where TEntity : Entity<TKey> where TKey : struct { // do stuff return...

How to check if a textbox has a line from a TXT File with C#

c#,textbox,.net-4.5,streamreader

string usersTXT = sr.ReadLine(); Reads exactly one line. So you are only checking if you match the first line in the file. You want File.ReadALlLines (which also disposes the stream correctly, which you aren't): if (File.ReadAllLines(usersPath).Contains(user_txt.Text)) { } That reads all the lines, enumerates them all checking if your line...

Azure Active Directory and Windows Authentication

azure,visual-studio-2013,.net-4.5,azure-active-directory

No, Windows authentication depends on Kerberos (or NTLM), which needs an Active Directory domain to authenticate the user in. Azure Active Directory does not handle Kerberos tokens. You can have your users authenticate against ADFS using the Kerberos protocol and federate the security token in ACS....

Delphi COM vs DLL in .NET [closed]

.net,delphi,.net-4.5

The issue of versioning a Win32 DLL and a COM library is a very specific implementation detail that has little to do with which of the two approaches is most suitable for consumption by a .NET client. Versioning COM versioning relies on consistent application of prescribed practices. It is possible...

How to 'sneak' interface behind 3rd party objects

c#,interface,.net-4.5

What you need is adapter pattern. You can create classes that implements your interface and use Foo & Bar in the background: interface IFooBar { string A { get; set; } string B { get; set; } } class FooAdapter : IFooBar { private readonly Foo _foo; public FooAdapter(Foo foo)...

Interface implementation with optional arguments

c#,.net,.net-4.5,c#-5.0

Because optional arguments in C# are just syntactic sugar. The method definition in your case is void Store(string payload, bool swallowException) rather than void Store(string payload) Which obviously doesn't match the interface. The way default arguments work is that the compiler injects the default values into the call of the...

Is there no Async implementation of MSMQ send in .net 4.5

.net,c#-4.0,.net-4.5,msmq

There should be no need for an asynchronous version of Send because Send is asynchronous. From MSDN Sending messages in Message Queuing is always an asynchronous operation. When you are sure the queue is open, you can continue to send messages without stopping to wait for a reply. Even for...

Is there an elegant LINQ solution for SomeButNotAll()?

c#,linq,.net-4.5,c#-5.0

I don't think you really need regexen for this. Here's how I would do it: var withEndings = new HashSet<string>(); var withoutEndings = new HashSet<string>(); foreach (var s in input) if(char.IsLower(s[s.Length - 1])) withEndings.Add(s.Substring(0, s.Length - 1)); else withoutEndings.Add(s); var result = withEndings.Intersect(withoutEndings); ...

How to set source for Image Control where the image resides in application folder

c#,wpf,.net-4.5

You'll have to specify that it is a relative URI by setting UriKind.Relative: var uri = new Uri(@"..\..\Assets\Images\Image001.jpeg", UriKind.Relative); That said, your BitmapFromUri method might be redundant (unless you have a reason to set BitmapCacheOption.OnLoad). You may probably as well use the BitmapImage constructor that takes an Uri parameter: previewImage.Source...

SignalR and Websockets on Mono

c#,.net,mono,.net-4.5,owin

I have made similar investigation about 3 months ago a project with Angular 2 and and Singnalr. I hope, the web socket usage is not essential for your project. As you can see here one of the Xamarin developers stated, it is not working as System.Web.WebSocket is not implemented in...

Cannot catch FileNotFoundException

c#,wpf,exception-handling,.net-4.5

If you run your code under debugger control, the debugger will always intercept exceptions before your catch block. The question is whether or not the debugger displays a message, and that depends on debugger settings. If the debugger handles an exception by displaying a message, it's then up to you...

Grouping extension methods

c#,.net,selenium,.net-4.5,extension-methods

It's not directly possible to group extension methods like that. In the example driver.Wills.MainCustomer.SetTitle("Dr"); you can make Wills and MainCustomer methods that each return a specialized type. The next level (MainCustomer and SetTitle) of drilling in can then key off of those types. Search for "fluent style" to see what...

Exception when opening all VS 2013 solutions after installing .net framework 4.5.2

visual-studio-2013,.net-4.5

I ran the commands in this answer and it solved my problem: 1.devenv.exe /safemode 2.devenv.exe /resetskippkgs 3.devenv.exe /installvstemplates 4.devenv.exe /resetsettings 5.devenv.exe /resetuserdata...

TLS_PSK_WITH_AES_128_GCM_SHA256 ciphersuite in C#

c#,ssl,.net-4.5

I found a working implementation of bounty castle, this has a mockPSKServer and client and supports the desired cipher suite. https://github.com/bcgit/bc-csharp...

IL Emit struct serializer

c#,.net,.net-4.5,code-generation,reflection.emit

There are a few problems. Firstly, your use of parameterName for Ldarga_S is incorrect, it should be (byte)0. Note that the byte cast is required to ensure you're calling the correct Emit() overload - Ldarga_S takes a byte parameter, but without the cast you're calling the overload with int as...

How to get distance between two locations in Windows Phone 8.1

c#,windows-phone-8,windows-phone-8.1,.net-4.5

GeoCoordinate.GetDistanceTo() is found in System.Device.Location namespace. But windows 8.1 (Runtime apps) apps use Windows.Devices.Geolocation namespace where GetDistanceTo() method is not present. So you can calculate the distance yourself by using the Haversine formula. Here is the wikipedia Haversine page, you can know about the formula from there. You can use...

Culture-aware string comparison for Umlaute

c#,.net-4.5,string-comparison

I had the same issue and found no other solution then replacing them e.g. by a extension. As far as i know there is no "direct" solution for this. public static string ReplaceUmlaute(this string s) { return s.Replace("ä", "ae").Replace("ö", "oe").Replace("ü", "ue").Replace("Ä", "AE").Replace("Ö", "OE").Replace("Ü", "UE"); } Result: int compareResult = String.Compare("jörg".ReplaceUmlaute(),...

LINQ Replace Different String Values

c#,linq,.net-4.5

FileInfo fi = new FileInfo(@"C:\temp\Addresses.txt") var ZipCodesAndCountryCodes = File.ReadLines(fi.FullName).Select(l => { var countrySubstr = l.Substring(1405,30); return new { ZipCode = l.Substring(1395, 5), CountryCode = string.IsNullOrWhiteSpace(countrySubstr) || countrySubstr == "USA" || countrySubstr == "United States" || countrySubstr == "United States of America" ? "US" : countrySubstr }; }); ...

.Net project executable can use 32 bit drivers only when NOT “run as administrator”

c#,visual-studio-2013,.net-4.5,wow64

I got that problem for a MySQL DataSource, that's because your DataSource is registered only for your current user, not Machine-wide. When the application is ran as an administrator, the program is looking in the machine wide data sources To register your DataSource System-Wide, open your Configuration Panel, in the...

Not allowed to load assembly from network location

.net,visual-studio-2012,.net-4.5,.net-assembly

Adding the loadFromRemoteSources switch to the machine.config file solved the problem.

ClickOnce deployment requires Framework 4.5 required when 4.5.2 is installed

c#,.net,.net-4.5,clickonce

Problem has been solved. On my machine was installed framework 4.5.2 but it was english language oriented version. From this place I found it out.This link helped me either. My application is russian language oriented, so I had to install framework 4.5.2 special for russian language. That's why I downloaded...

Calling Stop Timer in Timer.Tick

c#,timer,.net-4.5

I think if call myTimer.Stop() or myTimer.Enable = false, the Tick method will run to the end but there won't be the next Tick. Correct. Stopping the timer will not kill the thread executing the callback function. Your Tick method will continue to run until it returns. You can...

Change Backgroundcolor of TabControl

c#,wpf,.net-4.5,ribbon

I can't comment, because I don't have enough reputation yet. The RibbonTabHeader has the following properties: CheckedBackground - Gets or sets the brush that is used to draw the background of the control when it is in the Checked state. FocusedBackground - Gets or sets the brush that is used...

In pure XAML, is it possible to select a string format on the fly?

c#,wpf,xaml,.net-4.5

Easy peasy with a couple of DataTriggers: <Grid x:Name="LayoutRoot"> <Grid.RowDefinitions> <RowDefinition /> <RowDefinition /> </Grid.RowDefinitions> <ListBox Grid.Row="0" ItemsSource="{Binding Currencies}" SelectedItem="{Binding SelectedCurrency, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" DisplayMemberPath="Name" /> <TextBlock FontSize="30" Grid.Row="1"> <TextBlock.Style> <Style TargetType="TextBlock"> <Setter Property="Text" Value="{Binding Price,...

Overridden Extension Method Requires Assembly Reference [duplicate]

c#,.net,generics,.net-4.5,extension-methods

What is the base class of Universe.SolarSystemCelestial? Its something to do with the return type either being in a different assembly, or one of its base types, or types that it exposes publicly is in the other assembly. EDIT: After reading the question again with extra comments, the problem is...

Set HTTP protocol version in HttpClient

c#,http,httpclient,.net-4.5

In order to set the version you'll have to create an instance of HttpRequestMessage and set its Version property which you pass to HttpClient.SendAsync. You can use the helper HttpVersion utility class: var requestMessage = new HttpRequestMessage(); requestMessage.Version = HttpVersion.Version10; var client = new HttpClient(); var response = await client.SendAsync(requestMessage);...

How to use wcf ServiceBehavior attribute for InstanceContextMode in Web API?

asp.net,wcf,.net-4.5,web-api,asp.net-web-api2

The ServiceBehaviorAttribute is in the System.ServiceModel namespace and is used exclusively for WCF not for Web API. The following link seems to address your issue: Programmatically set InstanceContextMode

HmlAgilityPack fix not open tag

c#,html,.net-4.5,html-agility-pack

for this particular problem you could do simple regex replacing: string wrong = "<table class=\"transparent\"><tr><td>Sąrašo eil. Nr.:</td><td>B-FA001</td></tr><td>Įrašymo į Sąrašą data:</td><td>2006-11-13</td></tr></table>"; Regex reg = new Regex(@"(?<!(?:<tr>)|(?:</td>))<td>"); string right = reg.Replace(wrong, "<tr><td>"); Console.WriteLine(right); ...

How to setup multiple async methods into a queue?

c#,.net,queue,async-await,.net-4.5

There are many possible designs for this. But I always prefer TPL Dataflow. You can use an ActionBlock and post async delegates into it to be processed sequentially: ActionBlock<Func<Task>> _block = new ActionBlock<Func<Task>>(action => action()); block.Post(async () => { await Task.Delay(1000); MessageBox.Show("bar"); }); Another possible solution would be to asynchronously...

Service not accessible when “Enable 32-Bit Applications” set to true

web-services,iis-7.5,.net-4.5,windows-server-2008

Step 1: Enable Logging in IIS In Order to enable better error messages and log files in IIS you must install two Features: Control Panel->Programs and Features->Turn Windows features on or off You'll need two features installed: WebServer->Common Http Features->HTTP Errors WebServer-> Health an Diagnostics->HTTP Logging Step 2: Analyse Error...

LINQ anonymous object is inaccessible due to its protection level

c#,linq,.net-4.5,anonymous-types

You are currently creating a list of anonymous types which have a single property, Info, that is a Dictionary<string, string>. You don't appear to be capturing the result in a variable. Then you try to access Info as if it were a single object outside of the RegEx query. Those...

What is the best way to determine max amount of threads for C# IO operations based on the system's hard drive?

c#,multithreading,.net-4.5

I don't think the OS really 'knows' what kind (HDD/SDD) of drive you have. It might be possible to find out about RAID configurations through WMI but I'm not sure if that is reliable (some RAIDs are fully implemented in hardware). And even if you know about your drive, there...

Does System.Linq.Dynamic support .net 4.5?

c#,linq,.net-4.5

I don't see why not: ` .NET Framework 4.5 is a high compatible in-place update that replaces .NET Framework 4 Source...

Common ways to tweak the .NET 4.5 GC for games and other real time applications?

.net,garbage-collection,.net-4.5

Start with profiling. Find out what's giving you trouble and find a way to get rid of that. There's a few tweaks like using the multi-threaded GC, but that only really helps much for server applications with a few worker threads. Your best bet is to make sure most of...

HttpClient: Conditionally set AcceptEncoding compression at runtime

c#,gzip,.net-4.5,dotnet-httpclient,winrt-async

As per the comments above, recreating the HttpClient is really the only (robust) way to do this. Manual decompression can be achieved but it seems to be very difficult to reliably/efficiently determine whether the content has been encoded or not, to determine whether to apply decoding.

C# How do I stop code from looping during collection serialization causing a stackoverflow?

c#,serialization,collections,.net-4.5

Your indexer will always loop indefinitely, regardless of whether you're using it in a serialization context or not. You probably want to call the base indexer inside it like this: public Section this[int index] { get { return (Section)base[index]; //loops here with index always [0] } set { base[index] =...

ConcurrentBag vs Custom Thread Safe List

c#,multithreading,concurrency,.net-4.5,readerwriterlockslim

Why are the results so different when the only thing I’m changing is the ordering of the tasks within the list? My best guess is that Test #1 does not actually read items, as there is nothing to read. The order of task execution is: Read from shared pool...

Checking if List> is empty

c#,collections,tuples,.net-4.5

explanation of not working part :- it not working because you are intializtion your collection like this List<Tuple<byte, string>> intermediateResult = new List<Tuple<byte, string>>(); when you intialize like this than intermediateResult is not null. which is true....

Handling different item templates that share the same content

wpf,wpf-controls,.net-4.5

Obviously duplicating the code is not a very good solution. A better approach is to define another DataTemplate as your common content and then use ContentPresenter to present it: <Window.Resources> <DataTemplate x:Key="CommonTemplate"> <TextBlock Text="{Binding CommonProperty1}" /> <TextBlock Text="{Binding CommonProperty2}" /> </DataTemplate> <DataTemplate x:Key="Template1" > <StackPanel> <ContentPresenter ContentTemplate="{StaticResource CommonTemplate}"/> <TextBlock Text="{Binding...

Web API Sync Calls Best Practice

c#,iis,.net-4.5,web-api

Using Task<T>.Result is the equivalent of Wait which will perform a synchronous block on the thread. Having async methods on the WebApi and then having all the callers synchronously blocking them effectively makes the WebApi method synchronous. Under load you will deadlock if the number of simultaneous Waits exceeds the...

Lambda not equal on join

c#,.net,lambda,.net-4.5

If you want to do it in purely lambda: var match = categorys.Join(filterCategorys, x => x.Id, y => y.CategoryId, (x, y) => new { Id = x.Id }); var filteredList = categorys.Where(x => !match.Contains(new {Id = x.Id})); I haven't measured the performance of this, but for 70 records, optimization is...

400 Bad Request when calling wcf from html using XDomainRequest

javascript,wcf,internet-explorer-9,.net-4.5,xdomainrequest

Apparently, the problem came from a typo from the real source file (typo that doesn't appear here) The code that you see above works. I will leave my question here because it seems that it is the right way to proceed and if it doesn't function for you as it...

Writing a file using NPOI

c#,.net,.net-4.5,npoi

I was unable to figure out a way of doing it reliably with NPOI. The files created by the utility always came out corrupted. I switched over to EPPlus for xlsx. The resulting code looks like this: public void SetValue(int row, string column, string value) { row += 2; //EPPlus...