STILL trying to wrap an unmanaged C++ class that is itself a wrapper to some
COM stuff, not sure, it is littered with LPDISPATCH and InvokeHelper, etc.
Problem is, when something goes wrong, I'm having a hard time debugging.
In my managed C++ class(the one wrapping the unmanaged C++) I have a method
that looks like this:
bool FindFileItem(St ring* filename, IVSSItem& founditem);
that method calls the unmanaged method:
bool FindFileItem(PC STR filename, IVSSItem& founditem);
identical. When I call the managed method from my C# code, the IVSSItem&
reference is a pointer (intellisense says that I need to specify a
IVSSItem*)
I suspect somewhere in here is where my crash is originating. I can avoid
the crash by created an IVSSItem object in the body of my unmanaged method
and assign to it rather than the IVSSItem reference.
I really am in over my head. Once I get this wrapper class to behave, I can
move past all this and get back to C# only, but for now I'm stuck here.
Does anyone have any clues or hints for me?
Thanks for any help.
Just in case, I have posted the relevant code below:
------- C# code that calls managed C++ wrapper class --------
private bool AssetExists(str ing extension, ref string filename)
{
unsafe
{
IVSSItem item;
if(sourceSafe.F indFileItem(fil ePath, &item) == true)
{
return true;
}
}
return false;
}
------ Managed C++ code that wraps the unmanaged C++ code -------
bool CSUSSWrapper::F indFileItem(Str ing* filename, IVSSItem& founditem)
{
char* pFilename =
(char*)(void*)M arshal::StringT oHGlobalAnsi(fi lename);
bool result = m_objSourceSafe->FindFileItem(p Filename, founditem);
Marshal::FreeHG lobal(pFilename );
return result;
} 1 3034
The crash is moving around , but it happens on this line often:
IVSSItem(const IVSSItem& dispatchSrc) : COleDispatchDri ver(dispatchSrc ) {}
With this error:
An unhandled exception of type 'System.NullRef erenceException ' occurred in
suabwrapper.dll
Additional information: Object reference not set to an instance of an
object.
"sklett" <as***@asdfasdf sd.com> wrote in message
news:us******** ******@TK2MSFTN GP14.phx.gbl... STILL trying to wrap an unmanaged C++ class that is itself a wrapper to
some COM stuff, not sure, it is littered with LPDISPATCH and InvokeHelper, etc.
Problem is, when something goes wrong, I'm having a hard time debugging.
In my managed C++ class(the one wrapping the unmanaged C++) I have a
method that looks like this: bool FindFileItem(St ring* filename, IVSSItem& founditem);
that method calls the unmanaged method: bool FindFileItem(PC STR filename, IVSSItem& founditem);
identical. When I call the managed method from my C# code, the IVSSItem& reference is a pointer (intellisense says that I need to specify a IVSSItem*)
I suspect somewhere in here is where my crash is originating. I can avoid the crash by created an IVSSItem object in the body of my unmanaged method and assign to it rather than the IVSSItem reference.
I really am in over my head. Once I get this wrapper class to behave, I
can move past all this and get back to C# only, but for now I'm stuck here. Does anyone have any clues or hints for me?
Thanks for any help.
Just in case, I have posted the relevant code below:
------- C# code that calls managed C++ wrapper class -------- private bool AssetExists(str ing extension, ref string filename)
{
unsafe
{
IVSSItem item;
if(sourceSafe.F indFileItem(fil ePath, &item) == true)
{
return true;
}
}
return false;
}
------ Managed C++ code that wraps the unmanaged C++ code -------
bool CSUSSWrapper::F indFileItem(Str ing* filename, IVSSItem& founditem)
{
char* pFilename = (char*)(void*)M arshal::StringT oHGlobalAnsi(fi lename);
bool result = m_objSourceSafe->FindFileItem(p Filename,
founditem); Marshal::FreeHG lobal(pFilename );
return result;
}
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Dmitry |
last post by:
Hi,
I have defined interface for COM components which inludes an argument being
filled with additional error info, if such occurs. If inside I raise COM
Error, I populate that parameter.
In COM environment this architecture works beautifully -- caller application
gets negative HRESULT and error description from IErrorInfo object, and
additional "log" information from that "ref" parameter:
In .Net it just never returns that paramter...
|
by: Ekim |
last post by:
hello,
I'm allocating a byte-Array in C# with byte byteArray = new byte;
Now I want to pass this byte-Array to a managed C++-function by reference,
so that I'm able to change the content of the byteArray and afterwards see
the changes in C#.
(if you wanna know more details: the goal is to write the content of an
existing char-array in c++ precisely into the passed byteArray, so that
after the function has proceded the content of the...
|
by: Gilad Walden |
last post by:
I use C# in .NET framework.
I have an ActiveX implemented in C++ that has a COM interface method that
gets as it’s out parameter a BSTR* . The interop translates this BSTR* into
C# string. From my managed code, I am calling that function with ‘out’
parameter of ‘string’ type. For normal size strings it works fine, but when
the string is very big (> 50,000 bytes), I get a null exception from the COM
interop.
What is the reason?...
|
by: simon.duvall |
last post by:
Hey all,
Was referencing various COMs, and tried using the Windows Genuine
Advantage 1.0 Type Library.
There's a cool method called GetMachineDetails() that I wanted to try,
but for some reason I'm getting an ACCESS DENIED HRESULT error when I
do.
Here's my code:
|
by: Frustrated |
last post by:
Since C# and VB.NET are similar, I am posting this here also
I have a C++ DLL that I need to access from VB.NET or C#. The
following is my attempt via VB.NET.
The function I am trying to call is declared like this:
void* PASCAL iidc_lockdata( HIIDC, long frame = -1 )
This function returns a pointer to unsigned chars
| |
by: omantawy |
last post by:
Hi,
I have some legacy ASP web applications that use an unmanaged COM
component to connect to a third party application. The third part
application has moved to the managed code in the current release with
backward compatibility with the unmanaged code.
In the future releases, the vendor is going to drop backward
compatibility and as a result of that all our legacy ASP applications
will break.
|
by: amazon |
last post by:
Our vender provided us a web service:
1xyztest.xsd file...
------------------------------------
postEvent PostEventRequest
-------------------------------------
authetication authentication
eventname string
source string
ID string
|
by: David Lowndes |
last post by:
The following example illustrates something that's taken me a while to
suss out (debugging someone else's code :( )...
The crux is that the code compiles cleanly at W4, and the issue is
that I'm passing a property by reference to a function that's trying
to modify it.
Needless to say the result isn't what was intended as the property
doesn't get modified.
|
by: arnuld |
last post by:
-------- PROGRAMME -----------
/* Stroustrup, 5.6 Structures
STATEMENT:
this programmes *tries* to do do this in 3 parts:
1.) it creates a "struct", named "jd", of type "address".
2. it then adds values to "jd"
3.) in the end it prints values of "jd".
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |