I have been desperately trying to solve a problem where I am wrapping
an unmanaged dll with managed extensions for c++ and then calling the
managed dll functions from C#. However, whenever I call the new
operator to create a new instance of the unmanaged class, I get the
following error:
An unhandled exception of type 'System.NullRef erenceException ' occurred
in objectblox.epsi lon.dll
Additional information: Object reference not set to an instance of an
object.
Below is the code that I have written. Also, please note that this does
work in Debug mode but not in release mode.
//////////////////////////////////////////////////////////////////////////
This is the C# code
//////////////////////////////////////////////////////////////////////////
using System;
using System.Collecti ons;
using ObjectBlox.Epsi lon;
namespace HelloWorldTutor ial
{
public class EntryPoint
{
[STAThread]
public static void Main(string[] args)
{
String configFile = "config.xml ";
Application app = new Application();
}
}
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
This is the managed c code
//////////////////////////////////////////////////////////////////////////
----Application.h----:
#pragma once
#pragma unmanaged
#include "dtABC\applicat ion.h"
#pragma managed
namespace ObjectBlox
{
namespace Epsilon
{
public __gc class Application
{
private public:
dtABC::Applicat ion __nogc *pApp;
public:
Application();
~Application();
};
}
}
----Application.cpp----:
#include "Applicatio n.h"
#include <vcclr.h> // for PtrToStringChar s
namespace ObjectBlox
{
namespace Epsilon
{
Application::Ap plication()
{
this->pApp = __nogc new dtABC::Applicat ion();
}
Application::~A pplication()
{
}
}
}
Any clue as to what is going on? I have spent too much time trying to
figure this out. Thanks for any light you can shed on this.
Steve Roberts 1 1543 js*******@highs tream.net wrote: I have been desperately trying to solve a problem where I am wrapping an unmanaged dll with managed extensions for c++ and then calling the managed dll functions from C#. However, whenever I call the new operator to create a new instance of the unmanaged class, I get the following error [ . . . ]
Hi Steve. I haven't looked closely at your code, but whenever using
mixed-mode C++ you should be aware of the issues described in this article:
Mixed DLL Loading Problem http://msdn.microsoft.com/library/de...ingProblem.asp
This issue can manifest in almost any way, so it may be responsible for your
issue. I hope this helps.
--
Derrick Coetzee, MCP, MSFT (Speech Server)
This posting is provided "AS IS" with no warranties, and confers no
rights. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: David Kantowitz |
last post by:
I am trying to wrap a native-C++ DLL in managed C++, to
use in a .NET project.
The native code is compiled into a DLL, and I have created
a .def file that exports the mangled names of the symbols
I am going to use from the wrapper library.
The wrapper library has the code written that uses the
native classes, and wraps them to present an equivalent of
their interface for .NET.
|
by: Arthur Roodenburg |
last post by:
Hello,
I have a huge set of unmanaged C++ classes, which I wrapped in managed C++.
Everything is in one assembly.
Using my wrapper in C# works fine.
However, when I would like to use the wrapper in managed C++ I get the
following warnings and errors:
warning C4945: 'MyType' : cannot import symbol from 'mydll.dll': as
'MyNamespace::MyType' has already been imported from another assembly
|
by: Vinoth Kumar |
last post by:
Hi
I have created a unmanaged class in a header file UnManaged.h
class UnManaged
{
UnManaged(){}
~UnManaged(){}
void HelloWorld(){}
};
|
by: Jacob Cohen |
last post by:
Under VC7.1, I am trying to wrap a native-C++ DLL that contains C++
objects in a Managed-C++ class library for use in a C# project.
I created and compiled the native DLL under VC7.1 as a Win32 DLL C++
(unmanaged) project. I found the decorated names of the symbols I
wanted to export and created a .def file, so that it generated an
import library.
I took this import library and had my Managed-C++ class library link
against it. The...
|
by: Paul Kenny |
last post by:
Hi,
I am trying to expose the functionality of an unmanaged
C++ class to the other languages available in the .NET
Framework. I have decided to do this by wrapping the
unmanaged C++ class in a managed one. I have taken a look
at following sample code on how to do this.
http://longhorn.msdn.microsoft.com/lhsdk/ndp/vcmg_appendixs
amplecode.aspx
| |
by: Ola Sprauten |
last post by:
I got a .NET class library project where I have written a managed wrapper
for some unmanaged code. The managed wrapper is then used by a c# .net
application. The problem I am having is that the unmanaged code relies
heavily on LoadString to load strings from a resource string table. I added
a string table to the .NET class library project, and added all the
necessary entries, but it all fails when it when it calls
AfxGetResourceHandle()....
|
by: Roth |
last post by:
I have an unmanaged C++ dll that exports 2 classes and a stl list. I've had no trouble writting wrapper classes around the two exported classes with managed C++, but one class wants a list of pointers as a parameter
Unmanaged method
int Sum(MYVALUE_LIST list)
when i try to use MYVALUE_LIST and pass it to the unmanaged object i get a linker error
MFCSumGenerator_Managed.obj : error LNK2001: unresolved external symbol "public: __thiscall...
|
by: roni |
last post by:
hi.
i have gc class written in manged c++ , some of his data members are
__nogc pointers for arrays,structs..
and in that gc class methods i call to the unmaganged dll i wrap .
my question is ,if it better design to create new __nogc class that will
have all the unmanged
|
by: Lee Crabtree |
last post by:
More fun wrapping unmanaged code...
I have a class heirarchy that I need to expose to C#, so I need to wrap all
the classes. That's not a big deal, except for the base class, which is
abstract. Since you can't instantiate an abstract class, I can't use a
pointer to the unmanaged type to handle the function calls.
Is there a good way to do this?
Lee
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |