Is it possible to pass an argument by reference through
an event in C++ managed code? For example, can I do the
following?
public __gc class MyClass : public Control
{
public:
__event void MyEvent(bool &Cancel);
};
The compiler seems happy with this, and it goes ahead and
creates a DLL fine and dandy.
However, when I reference this DLL from my VB.NET
project, and attempt to do this:
Public WithEvents MyObject as MyClass
It causes the development environment to pop up a dialog
box saying "The operation could not be completed" the
moment I press Enter after typing the above line.
If I attempt to compile or run the code, I get this
error: "Visual Basic .NET compiler is unable to recover
from the following error: System Error &Hc0000005&
(Visual Basic internal compiler error). Save your work
and restart Visual Studio .NET."
If I remove the reference (&) from the event declaration
in the C++ project, then the VB.NET project works fine
(except I need to pass that argument by reference for a
working solution). It took me two days, through trial
and error, to determine it was the argument-by-reference
in that one event that was causing this error.
I also attempted a sample VB.NET project that defines an
event, passing an argument ByRef. This time, I was able
to include that DLL wihtout any problems.
' This class, defined in VB.NET works fine
Public Class MyVBClass
Public Event MyVBEvent(ByRef Cancel As Boolean)
End Class
Any thoughts? Is this just a .NET Development studio
bug, or is it really impossible to pass an argument by
reference through an event in C++ managed code?
Microsoft Development Environment 2003, Version 7.1.3008
Microsoft .NET Framework 1.1, Version 1.1.4322
I can work around the problem (sigh), by creating another
class that holds the "Cancel" boolean argument inside
that class and pass that class as a (by val) argument
through the event, but I really don't want to kludge up
my code that way. 4 4562 __event void MyEvent(bool &Cancel);
bool __gc *Cancel
or
Boolean *Cancel
should work.
Mattias
--
Mattias Sjögren [MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/
Please reply only to the newsgroup. __event void MyEvent(bool &Cancel);
bool __gc *Cancel
or
Boolean *Cancel
should work.
Mattias
--
Mattias Sjögren [MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Yes, that did it! THANK YOU! -----Original Message-----
__event void MyEvent(bool &Cancel);
bool __gc *Cancel
or
Boolean *Cancel
should work. Mattias
-- Mattias Sjögren [MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ Please reply only to the newsgroup. .
Yes, that did it! THANK YOU! -----Original Message-----
__event void MyEvent(bool &Cancel);
bool __gc *Cancel
or
Boolean *Cancel
should work. Mattias
-- Mattias Sjögren [MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ Please reply only to the newsgroup. . This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Sean Dockery |
last post by:
Which is the following is correct?
a) <form ... onSubmit="return checkData()">
b) <form ... onSubmit="return checkData();">
c) <form ... onSubmit="checkData()">
d) <form ... onSubmit="checkData();">
|
by: deko |
last post by:
I'd like to use a bit of code in the OnOpen event of a report:
=rptOpen(Me.ReportName), (Me.Tag) --this doesn't work
This does work:
Private Sub Report_Open(Cancel As Integer)
modHandler.rptOpen (Me.Report.Name), (Me.Tag)
End Sub
|
by: Frank Rizzo |
last post by:
I've got a number of user controls on the web page. How can I pass some
data to it? I don't see where the user control is instantiated in the
page code-behind page.
Thanks.
|
by: John |
last post by:
Hi
I open a word document from my vb.net app. Now I want to pass reference to
one of the classes in my vb.net app to word so it can access procedures in
the vb.net class. How can I pass the class reference to word from a vb.net
app?
Thanks
Regards
|
by: Todd |
last post by:
Is it possible to pass an argument by reference through
an event in C++ managed code? For example, can I do the
following?
public __gc class MyClass : public Control
{
public:
__event void MyEvent(bool &Cancel);
| |
by: sloan |
last post by:
How does one "pass thru" a Raised Event....
I am using the Adapter Pattern to sync up some different interfaces.
http://www.dofactory.com/Patterns/PatternAdapter.aspx
My Question is this:
|
by: darthghandi |
last post by:
I am creating a listener class that listens for incoming connections.
When I get an incoming connection, I want to signal an event to
happen and pass that connected socket to a different thread for the
real work. I want to continue to listen for more connections. So is
the socket I pass with the delegate a reference or a value? I thought
this might work:
public delegate void AcceptConnection(Socket sock);
public class Listener
|
by: =?Utf-8?B?U3dhcHB5?= |
last post by:
Can anyone suggest me to pass more parameters other than two parameter for
events like the following?
Event:
Onbutton_click(object sender, EventArgs e)"
Event handler:
button.Click += new EventHandler(Onbutton_click);
I want to pass more information related that event. & want to use that
|
by: raylopez99 |
last post by:
Keywords: scope resolution, passing classes between parent and child
forms, parameter constructor method, normal constructor, default
constructor, forward reference, sharing classes between forms.
Here is a newbie mistake that I found myself doing (as a newbie), and
that even a master programmer, the guru of this forum, Jon Skeet,
missed! (He knows this I'm sure, but just didn't think this was my
problem; LOL, I am needling him)
If...
|
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: 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: 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: 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.
| |