managed

Is this .tlh file correct, and if not, then how do I generate the correct one?

蓝咒 提交于 2019-12-07 13:44:25
问题 I am trying to call a .NET 4.0 dll from unmanaged C++ code. I followed the instructions in this Code Project article by Atul Mani. I built the .NET dll, and followed all the steps up to and including registering it with regasm. Next, I created an unmanaged C++ project and added this line at the start of the .cpp file: #import "D:\PathToMyCSharpProject\bin\Debug\com.DeviceServices.tlb" rename ("EOF","adoEOF") no_namespace named_guids raw_interfaces_only When I built the C++ project, a .tlh

How do I change the lookup path for .NET libraries referenced via #using in Managed C++?

半腔热情 提交于 2019-12-07 09:49:23
I developed a DLL in Managed C++ which loads some plugins (implemented in any .NET language) at runtime using System.Reflection.Assembly.LoadFile . The interface which is implemented by all plugins is implemented in C#. It's used by the Managed C++ code like this: #using <IMyPluginInterface.dll> // Make the 'IMyPluginInterface' type available ref class PluginManager { List<IMyPluginInterface ^> ^m_plugins; // Load all plugins in a well-known directory. void load() { for ( string dllFile in Directory.GetFiles( .., "*.dll" ) ) { // Lookup the type of the plugin object using Reflection Type

Marshaling byval C-structure as return value in C#

丶灬走出姿态 提交于 2019-12-07 09:00:01
问题 I have unmanaged code: ... typedef struct foo { int a; bool b int c; } FOO,*LPFOO; .... __declspec(dllexport) FOO __stdcall GetFoo() { FOO f; <some work> return f; } .... I've declare C# prototype for GetFoo function: [StructLayout(LayoutKind.Sequential, Pack = 1)] private struct Foo { public int a; public bool b public int c; }; [DllImport("foo.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)] [return:MarshalAs( UnmanagedType.Struct)] private static extern Foo

HOWTO: Call Managed C# Interface From Unmanaged C++ On WindowsCE Compact Framework

十年热恋 提交于 2019-12-07 03:54:25
问题 I have extensive unmanaged Windows CE 5 C++ code that provides a UI that I want to use in a new product by combining it with a large amount of newer business and communications logic written in managed C# on Windows CE 6 and the Compact Framework. The UI may know about the business logic, but I want the business logic ignorant of the UI such that I can later replace it with a managed version, or any other UI that I choose as a front-end. I found an article that describes how to use COM as the

Finding memory leaks in a managed Win8 metro app?

馋奶兔 提交于 2019-12-07 02:41:13
问题 I'm currently working on a metro game for Windows 8 using C# and SharpDX. The project is going well, but recently there's been a need to start tracking down memory leaks and I'm not really sure where to begin. The built in memory profiler in Visual Studio 11 doesn't work for metro apps yet, WinDBG can't seem to connect to metro apps (unless I'm using it incorrectly), and I'm having a hard time finding any information about looking at managed allocations in .NET 4.5 for metro. Does anyone have

Using unmanaged code from managed code

瘦欲@ 提交于 2019-12-07 02:25:48
问题 I have my project developed in MFC which is unmnaged code. Now i need to create a similar application in C#, by reusing most of the MFC classes. Is it possible to directly export class/struct/enum from MFC dll, so that i can import it in my C# using dllimport and use it.? 回答1: Yes, it is quite possible. You just need to be careful with the types. Many translate very nicely but some are quirky. The name of the concept you're searching for is COM interop. See here for a getting started tutorial

Arrays of strings in Managed C++

十年热恋 提交于 2019-12-06 23:15:41
问题 I'm trying to write an application in Managed C++, but I cannot work out how to declare an array of strings. String^ linet[]; throws an error 'System::String ^' : a native array cannot contain this managed type So I suppose there's a different way to do this for managed data types. What exactly is it? 回答1: Do you really mean Managed C++? Not C++/CLI? Assuming you're actually using C++/CLI (because of the error message you posted), there are two ways to do this: array<String^>^ managedArray =

What is an un/managed DLL? What is un/managed code? [duplicate]

烂漫一生 提交于 2019-12-06 20:19:02
问题 This question already has answers here : What is managed or unmanaged code in programming? (13 answers) Closed 6 years ago . Could someone please explain to me what an un/managed DLL is? And what is un/managed code? 回答1: You will get a fair idea on managed and unmanaged code in following article - http://www.developer.com/net/cplus/article.php/2197621/Managed-Unmanaged-Native-What-Kind-of-Code-Is-This.htm 回答2: Unmanged code will be compiled to machine language to run directly on the hardware.

JSF Managed bean in jar not instantiated

南笙酒味 提交于 2019-12-06 14:22:24
I have created two jsf projects in JSF. One of them is a base project that has a single session bean. This base project is packaged into a .jar file (with a /META-INF/faces-config.xml file) and included in the other project (the clientproj). The problem is that when I run the client project, the session bean in the base project is not instantiated, and I get a NullPointerException. Details are as follows: Base Project - Session Bean package sbeans; import javax.faces.bean.ManagedBean; import javax.faces.bean.SessionScoped; @ManagedBean @SessionScoped public class SessionBean { private String

Injecting a managed dll into a native process

[亡魂溺海] 提交于 2019-12-06 12:12:29
I'm trying to inject a managed c# dll into a native executable. I'm injecting the following code into the executable in order to load the CLR. I know the injection works, because when I inject the code into cmd.exe it outputs correctly. I know that CLRCreateInstance, pMetaHost->GetRuntime, pRuntimeInfo->GetInterface all return S_OK, but pClrRuntimeHost->Start() returns E_FAIL. This only happens when I inject the dll into a remote process. If I load the dll on my own process and call Main from there, all calls return S_OK and the managed code runs fine. Update: I've tried injecting the code