managed

GetLastError() and calling unmanaged code in a static library from C++ .NET

I made a static library in Visual C++ 2008 Express Edition. It compiles to Win32 code in a file called static.lib. The functions in this library call SetLastError() to indicate errors or success. I have already succeeded in including this static.lib in a C++ Win32 DLL, and calling the DLL from C# using p/invoke and DllImport and SetLa...

Passing a managed (C#) string[] array to a COM DLL.

Setup: I have a COM DLL that calls a method inside a managed C# DLL. This function returns a C# string[] array, which is marshaled to a SAFEARRAY. Problem: When I try to access the strings within the safearray I only get the first char of the string. What am I doing wrong? The code: // Pointer to the managed interface Databa...

Allocation of managed objects in Managed C++

Is it necessary to check for nullptr after allocating an object using gcnew? ...

Exchange mail attachment extraction using managed code

Does anyone know of a way to copy mail attachments of a particular extention from mail when they arrive from exchange 2003, into a shared directory using managed code? I know one way is to use vbscript, using sinks that exchange exposes. however I was wondering if anyone had seen a sample in managed code, perhaps using interop?? Any sa...

How to tell if method is called from Windows Service in .Net (managed) code

How can I tell if a method I am writing in managed code is being call from an interactive app vs a windows service? ...

How to invoke the screen saver in Windows in C#?

I'd like to invoke the user's screen saver if such is defined, in a Windows environment. I know it can be done using pure C++ code (and then the wrapping in C# is pretty simple), as suggested here. Still, for curiosity, I'd like to know if such task can be accomplished by purely managed code using the dot net framework (version 2.0 and a...

Possible to call C++ code from C#?

Hi, is it possible to call C++ code, possibly compiled as a code library file (.dll), from within a .NET language such as C#? Specifically, C++ code such as the RakNet networking library Would really appreciate it if anyone could give me some pointers on how to do this/point me in the general direction to get started doing this and I ...

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

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 nativ...

Arrays of strings in Managed C++

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? ...

How to read in Database Connection parameters?? Web.xml or via Managed Bean??

I have a web application that will be run on a windows 2003 server box. A http link will launch the web application(a jsp form) and that application opens up an oracle database(in the constructor). Different users will be using this application and each user will be sending his or her own username, password as well as the servername and ...

How do I call managed .NET code from my un-managed C++ code in Windows and vice versa?

I have a pure C++ application developed using VC 6.0. I would like this application to make use of a library developed in C#. How do I call the methods in the C# library from my native executable? I do not want to convert my un-managed C++ native application to managed code. Similarly, how do I do the reverse? Is PInvoke the only option?...

problem with dbConnection, reading in context-params from web.xml

i have some jsp code that reads in Servlet Context parameters from a web.xml file. these parameters hold database connection information so each time the SID or user/password or servername changesm, the programmer doesnt have to go re-code; the user can just change the web.xml file. <context-param> <description>database user name</des...

How do I do typeof(int) in Managed C++?

Hey guys, I am working on a project now and part of it uses Managed C++. In the managed C++ code, I am creating a DataTable. While defining the Columns for the datatable, I need to specify the Type of the column. In C#, that would: typeof(int) but how do I do that in Managed C++? Thanks! ...

Crash when using C# Assembly from Managed C++ DLL

Hi, On a Windows XP system, I'm writing a Mangaged C++ library which calls code in a C# Assembly. Unfortunately, as soon as I start referencing a symbol in the C# Assembly, running the Managed C++ library fails with this error (I copied this from the XP crash dialog): EventType : clr20r3 P1 : treeviewdemo.exe P2 : 0.0.0.0 P3 : 4a5d6d62...

Passing an unmanaged C++ structure by reference to a managed C++ method causes an access violation when the structure is referenced

I'm trying to pass this structure: #pragma unmanaged typedef struct { void* data; unsigned nlen; unsigned int type; } PARAMETER; To this class static method: #pragma managed private class __gc GlobalFunctions { static void WriteField(Object* object, PARAMTER& par, unsigned dec) { switch (par.type) { ...

Is it possible to make both a managed and unmanaged versions of the same C++ assembly?

We use a software from another company for one of our products. A developer from that company is kinda 'old' and works in C (no offence). We work in .Net 3.5 (C#). He asked me if it is possible, with the same source code (presumably in C, maybe C++), to create an assembly that he could compile both a managed and unmanaged version. Ar...

ASP.NET MVC website where users can add/remove pages

I'm developing a website for a client, in which they want to be able to manage content and add/remove pages. At the same time, some pages on the site will be interactive and provide custom reports for logged-in customers. I've started developing the site in ASP.NET MVC, because I wanted full control over rendering. However, I'm findin...

JSF+Facelets treating bean action as property

Guys, for some reason EL is not telling actions from properties. I have this page test.xhtml: <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.su...

Pass Bitmap object to unmanaged code

I have the following function in C++ managed (ref) class: public static void Transform(Bitmap^ img); I want to call it from C# managed code. What I do is this: Bitmap image = new Bitmap(100, 100); MyClass.Transform(image); Is this correct, or do I need to use fixed statement? If so, then how? Thank you. ...

Making a custom mesh in C# managed DirectX

I need to make a DirectX 3D mesh at run time using Managed DirectX from C#. I have not been able to locate any information on how to do this. No, I can't use a 3D modeler program to make my objects. They must be precisely sized and shaped, and I don't have ANY of the size or shape information until runtime. No, I can't build up the m...