managed

Is it possible to share an enum declaration between C# and unmanaged C++?

僤鯓⒐⒋嵵緔 提交于 2019-11-27 19:27:23
Is there a way to share an enum definition between native (unmanaged) C++ and (managed) C#? I have the following enum used in completely unmanaged code: enum MyEnum { myVal1, myVal2 }; Our application sometimes uses a managed component. That C# component gets the enum item values as ints via a managed C++ interop dll (from the native dll). (The interop dll only loads if the C# component is needed.) The C# component has duplicated the enum definition: public enum MyEnum { myVal1, myVal2 }; Is there a way to eliminate the duplication without turning the native C++ dll into a managed dll? You can

ODP.NET Oracle.ManagedDataAcess random ORA-12570 errors

一世执手 提交于 2019-11-27 12:18:56
问题 I'm trying to migrate to Oracle.ManagedDataAcess from unmanaged version and receiving randoms ORA-12570 TNS:packet reader failure. I don't know why this error starts, but once it starts, every subsequent request gives the same error for about 10-30 minutes, then it works again for another 10-30 minutes and so on. So it is a random of subsequent failures for some time then subsequent success Already tried a lot of things, to resume: The environment: Oracle.ManagedDataAcess version 12.1.2400 (4

Marshaling – what is it and why do we need it?

巧了我就是萌 提交于 2019-11-27 09:12:05
问题 What is marshalling and why do we need it? I find it hard to believe that I cannot send an int over the wire from C# to C and have to marshall it. Why can't C# just send the 32 bits over with a starting and terminating signal, telling C code that it has received an int ? If there are any good tutorials or sites about why we need marshalling and how to use it, that would be great. 回答1: Because different languages and environments have different calling conventions, different layout conventions

WinApi - GetLastError vs. Marshal.GetLastWin32Error

自闭症网瘾萝莉.ら 提交于 2019-11-27 04:13:48
问题 I tested a lot. But I found no disadvantages of those 2! But see the accepted answer. I read here that calling GetLastError in managed code is unsafe because the Framework might internally "overwrite" the last error. I have never had any noticeable problems with GetLastError and it seems for me that the .NET Framework is smart enough not to overwrite it. Therefore I have a few questions on that topic: in [DllImport("kernel32.dll", SetLastError = true)] does the SetLastError attribute make the

Difference between native and managed code?

大城市里の小女人 提交于 2019-11-26 23:54:33
问题 For example, when looking at the GlowCode profiler website it says: "GlowCode 6.2 and x64 profile native, managed, and mixed C++, C#, .NET code" What do they mean? 回答1: Native code is the code whose memory is not "managed", as in, memory isn't freed for you (C++' delete and C's free, for instance), no reference counting, no garbage collection. Managed code, you guessed it, is the code whose memory is free and allocated for you, garbage collection and other goodies. Mixed code is when you have

What is meant by “managed” vs “unmanaged” resources in .NET?

六眼飞鱼酱① 提交于 2019-11-26 23:49:24
What is meant by the terms managed resource and unmanaged resource in .NET? How do they come into the picture? The term "unmanaged resource" is usually used to describe something not directly under the control of the garbage collector . For example, if you open a connection to a database server this will use resources on the server (for maintaining the connection) and possibly other non-.net resources on the client machine, if the provider isn't written entirely in managed code. This is why, for something like a database connection, it's recommended you write your code thusly: using (var

Difference between managed and unmanaged in-app product android?

大憨熊 提交于 2019-11-26 22:21:25
问题 I went through the developer forum to know the difference between managed an unmanaged in-app products. they are saying that "Items that are unmanaged do not have their transaction information stored on Android Market, which means you cannot query Android Market to retrieve transaction information for items whose purchase type is listed as unmanaged. You are responsible for managing the transaction information of unmanaged items." What does it mean? When i test the in-app product for both

Wrapping unmanaged C++ with C++/CLI - a proper approach

岁酱吖の 提交于 2019-11-26 21:37:12
问题 as stated in the title, I want to have my old C++ library working in managed .NET. I think of two possibilities: 1) I might try to compile the library with /clr and try "It Just Works" approach. 2) I might write a managed wrapper to the unmanaged library. First of all, I want to have my library working FAST, as it was in unmanaged environment. Thus, I am not sure if the first approach will not cause a large decrease in performance. However, it seems to be faster to implement (not a right word

Howto implement callback interface from unmanaged DLL to .net app?

本秂侑毒 提交于 2019-11-26 17:34:59
in my next project I want to implement a GUI for already existing code in C++. My plan is to wrap the C++ part in a DLL and to implement the GUI in C#. My problem is that I don't know how to implement a callback from the unmanaged DLL into the manged C# code. I've already done some development in C# but the interfacing between managed and unmanaged code is new to me. Can anybody give me some hints or reading tips or a simple example to start from? Unfortunatly I could not find anything helpful. You don't need to use Marshal.GetFunctionPointerForDelegate(), the P/Invoke marshaller does it

A call to PInvoke function '[…]' has unbalanced the stack

↘锁芯ラ 提交于 2019-11-26 16:32:01
I'm getting this weird error on some stuff I've been using for quite a while. It may be a new thing in Visual Studio 2010 but I'm not sure. I'm trying to call a unamanged function written in C++ from C#. From what I've read on the internet and the error message itself it's got something to do with the fact that the signature in my C# file is not the same as the one from C++ but I really can't see it. First of all this is my unamanged function below: TEngine GCreateEngine(int width,int height,int depth,int deviceType); And here is my function in C#: [DllImport("Engine.dll", EntryPoint =