managed

How to call a Managed DLL File in C#?

守給你的承諾、 提交于 2019-12-29 07:17:48
问题 I am making a scripting language but I have a serious problem. I need to make it so you can call .NET DLLs in the language but I have found no way to do this in C#. Does any one know how can I load and call a .NET dll programmatically? (I can not just Add reference so don't say that) 回答1: Here's how I did it: Assembly assembly = Assembly.LoadFrom(assemblyName); System.Type type = assembly.GetType(typeName); Object o = Activator.CreateInstance(type); IYourType yourObj = (o as IYourType); where

What is the difference in managed and unmanaged code, memory and size?

让人想犯罪 __ 提交于 2019-12-28 07:36:12
问题 After seeing and listening a lot regarding managed and unmanaged code, and knowing the only difference is that managed is about CLR and un-managed is outside of the CLR, it makes me really curious to know it in detail. What is it all about, managed and unmanaged code, memory and size? How can code I write in C# be unmanaged while this is C# code and how does a memory of size becomes unmanaged. An example and a little insight would be helpful. 回答1: Short answer: Managed code is .NET code (VB

The Symbol file MyFile.pdb does not match the module

删除回忆录丶 提交于 2019-12-24 02:58:05
问题 I've searched on this issue, and found many flavors and ideas but no real solutions. So, donning my asbestos suit and hoping for the best, I'm going to dare ask it again. I have managed C# code that calls managed C++ code, which in turn calls unmanaged C++ code. The unmanaged C++ code is throwing an exception, and I'd like to be able to debug through it. However, when I try to (explicitly, via the Call Stack) load the symbols, I get the dreaded "The symbol file MyFile.pdb does not match the

Calling unmanaged dll from C#. Take 2

爱⌒轻易说出口 提交于 2019-12-24 01:09:50
问题 I have written a c# program that calls a c++ dll that echoes the commandline args to a file When the c++ is called using the rundll32 command it displays the commandline args no problem, however when it is called from within the c# it doesnt. I asked this question to try and solve my problem, but I have modified it my test environment and I think it is worth asking a new question. Here is the c++ dll #include "stdafx.h" #include "stdlib.h" #include <stdio.h> #include <iostream> #include

In Eclipse CDT shared resource folder that is built differently for the project

好久不见. 提交于 2019-12-24 01:07:14
问题 I have a set of Eclipse c projects that will all refer to a common shared base of code (a mix of .c and .h files in the same folder) but will be built that code differently on a per project basis. The common code base may be edited from within each project but these edits will be fixes to be carried across all the projects. The common code will no diverge per project except for build options through defines. If I create a project for this library it implies a library build with is not what I

How can I mark as read all emails fetched through EWS in a single update?

风格不统一 提交于 2019-12-23 21:24:26
问题 I followed the EWS Managed API example on MSDN to find all unread email in my Exchange mailbox account. I later went through each found item in order to place them in the list I need to return while fetching the body of each message and updating each to IsRead=true as follows: Folder.Bind(Service, WellKnownFolderName.Inbox); SearchFilter sf = new SearchFilter.SearchFilterCollection(LogicalOperator.And, new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, false)); //ItemView limits the

Managed to unmanaged code call causes access violation… sometimes

非 Y 不嫁゛ 提交于 2019-12-23 14:02:04
问题 This code causes the following exception, sometimes : "Attempted to read or write protected memory. This is often an indication that other memory is corrupt" private static TOKEN_GROUPS GetTokenGroups(IntPtr tokenHandle) { var groups = new TOKEN_GROUPS(); uint tokenInfoLength = 0; uint returnLength; var res = GetTokenInformation(tokenHandle, TOKEN_INFORMATION_CLASS.TokenGroups, IntPtr.Zero, tokenInfoLength, out returnLength); if (!res && returnLength > 0) { tokenInfoLength = returnLength; var

Memory leak problems: dispose or not to dispose managed resources?

泪湿孤枕 提交于 2019-12-23 05:44:11
问题 I experience strange memory leak in computation expensive content-based image retrieval (CBIR) .NET application The concept is that there is service class with thread loop which captures images from some source and then passes them to image tagging thread for annotation. Image tags are queried from repository by the service class at specified time intervals and stored in its in-memory cache (Dictionary) to avoid frequent db hits. The classes in the project are: class Tag { public Guid Id {

How do we distinguish between managed and unmanaged resources in C#? Is TextFieldParser unmanaged?

醉酒当歌 提交于 2019-12-23 04:47:14
问题 I recently learned how to use Microsoft.VisualBasic.FileIO.TextFieldParser to parse a text input. In the example given to me, the TextFieldParser is called using the keyword using using (var parser = new Microsoft.VisualBasic.FileIO.TextFieldParser(new StringReader(str))) Though after some further researches, I notice that the practice of using using keyword for TextFieldParser is not universal. As far as I understand, .Net Framework has both managed and unmanaged resource. And when we use

Is a WPF application managed code only?

落爺英雄遲暮 提交于 2019-12-22 10:28:09
问题 I want to use WPF in an app. I want to write it in C++. Does the application have to be managed? I know that I can mix managed with unmanaged. I'm wondering if I can have the whole application be unmanaged. 回答1: You can easily develop 99% of your WPF application in unmanaged code, but making it 100% unmanaged is quite difficult. WPF classes don't have a Guid attribute, so they won't work with COM. So constructing WPF objects such as Button and Window with 100% unmanaged code requires one of