clr

Async/ Await: why does the code that follows await is also executed on the background thread and not on the original primary thread?

北慕城南 提交于 2019-12-25 17:46:21
问题 Below is my code: class Program { static async Task Main(string[] args) { Console.WriteLine(Thread.CurrentThread.ManagedThreadId); string message = await DoWorkAsync(); Console.WriteLine(Thread.CurrentThread.ManagedThreadId); Console.WriteLine(message); } static async Task<string> DoWorkAsync() { return await Task.Run(() => { Thread.Sleep(3_000); return "Done with work!"; }); } } and the output is 1 // after 3 secs 3 Done with work! so you can see the main thread(id is 1) changed to worker

Call C++ Exported Function in C# [closed]

断了今生、忘了曾经 提交于 2019-12-25 09:08:42
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . I have the following C++ code: #pragma once #include "StdAfx.h" #include <string> using namespace std; using namespace System; extern "C" __declspec( dllexport ) string __stdcall GetVale() { return "test"; } I am

clr.dll causes 800703e9 on Microsoft .NET 4.6.1

帅比萌擦擦* 提交于 2019-12-25 07:15:05
问题 When using a DLL that works fine in a .NET-based Windows app in Excel 2013, it crashes the clr.dll: Application: EXCEL.EXE Framework Version: v4.0.30319 Description: The process was terminated due to an internal error in the .NET Runtime at IP 6F033A0F (6EDA0000) with exit code 800703e9. Faulting application name: EXCEL.EXE, version: 15.0.4833.1000, time stamp: 0x573ac30d Faulting module name: clr.dll, version: 4.6.1076.0, time stamp: 0x56d7a0ff Exception code: 0x800703e9 Fault offset:

Clr Assembly must have main file specified error

给你一囗甜甜゛ 提交于 2019-12-25 05:04:13
问题 This is the first dll I have made. It's purpose is to grab territory names from a database and return as an mdx set. The dll compiled perfectly fine, but when I go to deploy the dll as an assembly in bids to my cube, I get the following error: Clr Assembly must have main file specified error The dll is supposed to be like a ssas stored procedure so I can set permission in a role for ssas. Thanks! Ethan 回答1: I finally figured out a solution! I believe that because of the msmgdsv.dll being of

Passing objects between C# library and C++ (CLR)

对着背影说爱祢 提交于 2019-12-25 01:32:51
问题 How to pass objects from C# library to C++. I can call a function which returns void or int without any issue. Now consider the following function in C#, List<CSharpClass> CSharpFunction(string Input) where my C# class contains, public class CSharpClass { string mystring = string.Empty; byte[] bytearray = null; public byte[] bytearray { get { return bytearray ; } set { bytearray = value; } } public string mystring { get { return mystring ; } set { mystring = value; } } } Now, I want use this

Loop doesn't update listboxes until it is done iterating

丶灬走出姿态 提交于 2019-12-25 01:26:46
问题 I have a loop that takes file name from a listbox, performs a system() call, then moves that filename to another listbox. Problem is, it doesn't move the filenames over one at a time, but waits until the entire loop is finished and moves them all at once. What would I do to get it to perform how I want it to? the loop: for each( String^% file in filename ) { int x = convert( file ); lbComplete->Items->Add( lbFiles->Items[0] ); // place the completed file lbFiles->Items->Remove( lbFiles->Items

How to control the orientation of Drawstring?

隐身守侯 提交于 2019-12-24 16:54:30
问题 I want to draw a string as an axis label. When I draw the string with following code, I can read it "from the left". The base line of the text is at the left side. StringFormat format = CustomGraphics.StringFormat(ContentAlignment.MiddleCenter); format.FormatFlags |= StringFormatFlags.DirectionVertical; e.Graphics.DrawString(this.yAxis.Title.Text, this.yAxis.Title.Font, textBrush, e.Bounds, format); format.FormatFlags &= ~StringFormatFlags.DirectionVertical; I want to draw vertical but turn

How are asynchronous I/O methods processed

烂漫一生 提交于 2019-12-24 14:48:57
问题 After reading alot about async-await, I can only find the benefits of using it in GUI thread (WPF/WinForms). In what scenarios does it reduce the creation of threads in WCF services? Does a programmer must use async-await on every method in the service by choosing to implement async-await in web service? Making some non-async-await methods in a service full of async-await reduse the efficiency of my service? How? Last question - some say that using 'await Task.Run(()=>...)' is not a "real

Accessing a C++ non-member function from C# via reflection

本小妞迷上赌 提交于 2019-12-24 10:59:10
问题 I need to gain some run-time information about a C++ program, which is kinda difficult due to C++ not offering some sophisticated reflection mechanism. Now, my approach is to compile the C++ code using /clr and to reflect over the resulting assembly from C# (simply because I like that language more than C++). While this is all turning out more or less fine, I'm now stuck at a point where I need to actually run the program by calling its main method. Which is kind of frustrating considering

Crash when running a .NET 3.5 app on .NET 4

余生长醉 提交于 2019-12-24 10:40:18
问题 Our application is built using WinForms on .NET 3.5 This was tested specifically on Windows XP, although i am not sure whether it is OS related. Whenever i run it on a machine with .NET 4 only, it will crash, saying that it cannot find the .NET assemblies versioned 3.5. I am wondering why this does not happen automatically. For example, some 3rd party libraries install a policy of some sort, that when a newer version is installed, it will be used, even if your application was compiled against