.net

Using the .NET 4 Task library to display a blocking message box in WPF

有些话、适合烂在心里 提交于 2021-02-19 02:47:07
问题 I have the following code in my WPF application: Task task = Task.Factory.StartNew(() => { DoInitialProcess(); }); task.ContinueWith(t => Dispatcher.BeginInvoke((Action)(() => { MessageBox.Show("Error: " + t.Exception.InnerExceptions[0].Message); })), TaskContinuationOptions.OnlyOnFaulted); It successfully triggers the continuation and displays the message box if an exception occurs, but it does not block input on the main UI thread. Why doesn't it block the main UI thread, and what is the

Assembly specific settings not loading at runtime

好久不见. 提交于 2021-02-19 02:43:05
问题 I am developing a .NET 3.5 Windows Forms app. I have two projects, the UI and a Library. UI uses strongly typed settings that are stored, as usually, in the app.config file. I read them using UI.Properties.Settings class (generated by Visual Studio). Library uses its own strongly typed Settings (the Settings.settings file that is dumped into Library.config file). At runtime, Library settings will not reload from the Library.config file. Only UI.config file is read by the runtime. So I am

Indexer named “Item” required by interface but not possible to implement?

心已入冬 提交于 2021-02-19 02:37:20
问题 I'm trying to implement an interface of a class in the ESPRIT api that requires an indexer named "Item." (I'm guessing the interface came from VB.NET but I don't have the source.) Obviously the "Item[index]" indexer is auto-generated by the compiler by default but I'm getting the following errors: I realize [System.Runtime.CompilerServices.IndexerName("Item")] is redundant; it's simply there to demonstrate explicitly that Item is generated and the error remains. Attempting to implement public

VB6 App + .Net component working as compiled app but not in VB6 IDE

戏子无情 提交于 2021-02-19 02:36:07
问题 I have a VB6 App that uses a .Net component (via a .tlb reference in the VB6 app) which is working fine when executed as a compiled app, but it produces an error from the VB6 IDE a certain point when it is trying to use the .NET component. I should note that the error occurs when the .NET component is meant to be invoking a third party reporting component. The error is specific to the reporting component. Something about not being able to cast from String to some other type. The .tlb is in

iOS <-> PC USB Communication [closed]

百般思念 提交于 2021-02-19 02:27:48
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 3 years ago . Improve this question Is it possible to establish a communication between an OSX (or Windows) Application, and an iOS App, via USB ? I just want my 2 App to be able to communicate with each other, read and write packets... I don't want to use WiFi Is there an "easy way" to do that

'Assert' statements in .NET production code

橙三吉。 提交于 2021-02-19 02:23:31
问题 Is it wise to leave Trace.Assert and Debug.Assert statements in code that is "stable" and which has been moved into Test and Production environments? If so, how do these assertion statements help? Isn't it sufficient to have Guard classes, etc. check for exception conditions and raise exceptions as appropriate? 回答1: Debug.Assert statements will be ignored unless you have the DEBUG compilation constant defined, which by default happens when you compile in the "debug" configuration and not in

Best alternative to Buffer.MemoryCopy pre .NET 4.6

ぐ巨炮叔叔 提交于 2021-02-19 02:03:48
问题 I'm trying to downgrade some .NET 4.6 code to .NET 4.5. This is the code block im working with at the moment: fixed (byte* destination = dataBytes) { Buffer.MemoryCopy(data, destination, dataLength, dataLength); } data is byte* type so I don't know if Buffer.BlockCopy() is a reasonable replacement since it takes in Arrays. Any ideas? 回答1: You are right that Buffer.MemoryCopy is .Net 4.6 or higher, Buffer.BlockCopy doesn't have the the desired overloads, and Array.Copy is out of the question

Generating a good hash code (GetHashCode) for a BitArray

非 Y 不嫁゛ 提交于 2021-02-19 02:02:32
问题 I need to generate a fast hash code in GetHashCode for a BitArray. I have a Dictionary where the keys are BitArrays, and all the BitArrays are of the same length. Does anyone know of a fast way to generate a good hash from a variable number of bits, as in this scenario? UPDATE: The approach I originally took was to access the internal array of ints directly through reflection (speed is more important than encapsulation in this case), then XOR those values. The XOR approach seems to work well

How to add private nuget source in dotnet dockerfile?

大城市里の小女人 提交于 2021-02-19 01:59:50
问题 I try to add (override) a private nuget source to my build script in order to add the user/pw - and keep it out of my source control. What I tried so far: nuget is not recognized as command inside the image dotnet nuget does not have the command to add additional sources installing nuget does not effect dotnet restore FROM mcr.microsoft.com/dotnet/core/sdk:2.2 RUN apt-get update && apt-get install -y nuget RUN nuget source Add -Name "Private Feed" -Source ".." -UserName "UserVAR" -Password

confusing of using == operator in c#

荒凉一梦 提交于 2021-02-19 01:58:04
问题 I am confusing about using == in (c#) when I use literal string like here: object a="hello"; object b="hello"; the comparison a==b will be true. but when I use object like here: object c=new StringBuilder("hello").ToString(); object d=new StringBuilder("hello").ToString(); the comparison a==b will be false. even though a,b,c,d all of type System.Object in compile time and == operator compare values depends on their values in compile time. I use extension method to get type of varabiles during