473,626 Members | 3,531 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help with delegate callback error

I have a class which processes for a relatively long time. I want to enable
other classes which call this one to receive process messages if they wish.

The called routine (the one defining the delegate) is named CASSPrintSQL in
namespace CASS. The code is:

Private Delegate Sub DisplayMessage( ByVal msg As String)
Private _msgListener As DisplayMessage
....
Public Sub OnDisplayMessag e(ByVal CallerMethod As DisplayMessage) '<== Error
_msgListener = CallerMethod
End Sub

The error is:
'CallerMethod' cannot expose type 'DisplayMessage ' in namespace 'CASS' through
class 'CassPrintSQL'.

I do not understand this compilation error. Can anyone help? Thanks, Flomo
--

Apr 30 '07 #1
9 2047
On Apr 30, 1:17 pm, "Flomo Togba Kwele" <F...@community .nospamwrote:
I have a class which processes for a relatively long time. I want to enable
other classes which call this one to receive process messages if they wish.

The called routine (the one defining the delegate) is named CASSPrintSQL in
namespace CASS. The code is:

Private Delegate Sub DisplayMessage( ByVal msg As String)
Private _msgListener As DisplayMessage
...
Public Sub OnDisplayMessag e(ByVal CallerMethod As DisplayMessage) '<== Error
_msgListener = CallerMethod
End Sub

The error is:
'CallerMethod' cannot expose type 'DisplayMessage ' in namespace 'CASS' through
class 'CassPrintSQL'.

I do not understand this compilation error. Can anyone help? Thanks, Flomo
--
You are exposing a private member of a class through a public method
(which is a no-no since it would override the private modifier).
Changing the delegate's modifier to public should fix the problem.

Thanks,

Seth Rowe

Apr 30 '07 #2
"Flomo Togba Kwele" <Fl***@communit y.nospamschrieb :
>I have a class which processes for a relatively long time. I want to enable
other classes which call this one to receive process messages if they
wish.

The called routine (the one defining the delegate) is named CASSPrintSQL
in
namespace CASS. The code is:

Private Delegate Sub DisplayMessage( ByVal msg As String)
='Public Delegate Sub...'.
Private _msgListener As DisplayMessage
...
Public Sub OnDisplayMessag e(ByVal CallerMethod As DisplayMessage) '<==
Error
_msgListener = CallerMethod
End Sub

The error is:
'CallerMethod' cannot expose type 'DisplayMessage ' in namespace 'CASS'
through
class 'CassPrintSQL'.

I do not understand this compilation error. Can anyone help? Thanks, Flomo
See above. The /public/ method exposes a parameter of type
'DisplayMessage ', which requires the delegate type 'DisplayMessage ' to be
visible outside the class too.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Apr 30 '07 #3
Thanks to you both for getting me over that hump.

Now to be greedy - it compiles but does not work as I expected. After
instantiating the object to be called, which also handles the delegate, I issue
the following in the calling routine:

cass.OnDisplayM essage(AddressO f GetMessage)
....
Private Sub GetMessage(ByVa l msg As String)
lblInfo.Text = msg
End Sub

where cass is the instance name of the called routine. In that routine I
defined:
Private Sub SendMessage(ByV al msg As String)
If _msgListener IsNot Nothing Then
_msgListener.Be ginInvoke(msg, Nothing, Nothing)
End If
End Sub

I called the SendMessage routine with different messages 6 times and I can see
this in the debugger. But I do not get any output in the Label. Any ideas?

Thanks again, Flomo
--

Flomo Togba Kwele wrote:
I have a class which processes for a relatively long time. I want to enable
other classes which call this one to receive process messages if they wish.

The called routine (the one defining the delegate) is named CASSPrintSQL in
namespace CASS. The code is:

Private Delegate Sub DisplayMessage( ByVal msg As String)
Private _msgListener As DisplayMessage
...
Public Sub OnDisplayMessag e(ByVal CallerMethod As DisplayMessage) '<==
Error _msgListener = CallerMethod
End Sub

The error is:
'CallerMethod' cannot expose type 'DisplayMessage ' in namespace 'CASS' through
class 'CassPrintSQL'.

I do not understand this compilation error. Can anyone help? Thanks, Flomo


--

May 1 '07 #4
Hello, Flomo,

Is the delegate defined in a class or user control? I tested following code:

Public Class Class1
Public Delegate Sub DisplayMessage( ByVal msg As String)
Private _msgListener As DisplayMessage
Public Sub OnDisplayMessag e(ByVal CallerMethod As DisplayMessage)
_msgListener = CallerMethod
End Sub
Public Sub SendMessage(ByV al msg As String)
If _msgListener IsNot Nothing Then
_msgListener.In voke(msg)
End If
End Sub

End Class

And tested it in a win form application, it seems to work well.

Sincerely,

Luke Zhang

Microsoft Online Community Support
=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

May 1 '07 #5
Thanks for responding, Luke.

The delegate is defined in a regular class (CassPrintSql) which does a lot of
processing. The calling routine is a UserControl providing the GUI interface.
That is the one which is supposed to display messages coming from CassPrintSql
(the one containing the delegate).

I used the BeginInvoke method on the delegate because some of the processes in
this class take more than a few minutes. If I don't use an asynchronous
delegate, the messages will be blocked until the entire class is complete.

I don't know why it didn't work as coded. Any ideas?

Thanks, Flomo
May 1 '07 #6
Hello,

If you just have a test, use invoke instead of beginInvoke(), what will
happen to the Messages?

Sincerely,

Luke Zhang

Microsoft Online Community Support
=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

May 2 '07 #7
Luke,

If I change from BeginInvoke to Invoke, the result is the same - no output to
GUI interface until the calling program is complete.

Flomo
--

May 2 '07 #8
Hello,

If you use a simple class instead of your original CassPrintSql, to define
the delegate, what will happen? I suspect other code in CassPrintSql may
cause the problem so that the delegate doesn't work correctly. I tested a
simple class on my side, and I didn't find the problem.

Sincerely,

Luke Zhang

Microsoft Online Community Support
=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

May 4 '07 #9
Luke,

Thanks for the reply. I had to call CSS.

Flomo

Luke Zhang [MSFT] wrote:
Hello,

If you use a simple class instead of your original CassPrintSql, to define
the delegate, what will happen? I suspect other code in CassPrintSql may
cause the problem so that the delegate doesn't work correctly. I tested a
simple class on my side, and I didn't find the problem.

Sincerely,

Luke Zhang

Microsoft Online Community Support
=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

May 7 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
287
by: Fred Gravel | last post by:
I have a Windows app that I have installed on 3 client machines (all win2k) thatreturn an un-handled error message when starting up. I have placed 'Try/Catch/Finally' blocks in the 'sub main' and it doesn't even get to there. Problem is the application works fine on my development PC. I have MDAC v2.8 and Framework 1.1 on all machines. I have cross checked all of the .dll versions and verified that they are the same as the ones on my...
3
2039
by: Jim | last post by:
I have a windows application that is accessing unmanaged code and providing a callback function that will create events at unknown time spans. When the EventHandler (callback function) fires it causes my program to crash or freeze, or do strange stuff. When I remove this callback function it works great. Problem is I need this callback function to implement my state machine for the program so I think I need to encapsulate this callback...
0
1554
by: Budi | last post by:
Hi, We try callback C# method from C++ DLL using delegate, using delegate without argument works fine for me however the CallBackFunctionWithParameter which call delegate with parameter crash the application after being called . Any suggestion will help and really appreaciated Thanks
0
4196
by: Feng | last post by:
Hi, I need my remoting server to callback to my client and I am trying to do that using delegate. While the client invoking the server OK, I am getting the following error when the server trying to callback to the client: "This remoting proxy has no channel sink which means either the server has no registered server channels that are listening, or this application has no suitable client channel to talk to the server." I have try all...
1
1218
by: Allerdyce.John | last post by:
I need some help in reading error message: which line has problem? line 233? or line 37? Thank you. $ ./read2.py log.xml Traceback (most recent call last): File "./read2.py", line 233, in ? parser.parse(open(inputFileName)) File "/usr/lib/python2.4/site-packages/_xmlplus/sax/expatreader.py",
5
1765
by: greg.merideth | last post by:
I have a class that I've provided an event for to be called when the processing in the class is complete (a callback). The class spins up a series of threads for the background operation and I'm firing the callback delgate from within one of the new threads. So far, all is well but I'm curious as to what, threading wise, is going on there. I'm instantiating the class in the app thread (say 1) and providing a method to call when...
5
1940
by: sajin | last post by:
Hi All.. We are using VB .Net 2005 for implementing an API. API needs to generate events. For this client wants us to use Windows Callback (delegate implementation). The intention of using Windows Callback is to generalise our API so that it can be compatible with any other language e.g. C++. Using normal delegates will not help us since delegates is a VB.Net feature and any other language cant make a use of it. Could please
1
4319
by: khgoh | last post by:
Hi, Need help for the error "OverflowError: long int too large to convert to int" while reading a zip file content. Python version: Python 2.4.1 (#1, Sep 13 2005, 00:39:20) on linux2 Code >>> import os, datetime, sys, optparse, string, operator, gzip >>> health_day_summary_file = gzip.GzipFile( "health_CORR_summary.csv.gz", "rb")
1
2114
by: psantosh12 | last post by:
Hello Frnds Please need help to resolve error.......... it is very very urgent........ The error is Runtime Error Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine. Details: To enable the details of...
0
8266
marktang
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...
0
8199
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,...
0
8705
Oralloy
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...
0
8638
jinu1996
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...
1
8365
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,...
0
7196
agi2029
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...
1
6125
isladogs
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...
1
1811
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1511
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.